Skip to content

Commit 458f639

Browse files
committed
add _set_row_factory() method
1 parent c31095b commit 458f639

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

simple_query_builder/querybuilder.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,23 @@ class QueryBuilder:
8080
_error_message: str = ""
8181
_print_errors: bool = False
8282
_result: Union[tuple, list] = []
83+
_result_dict = True
8384
_count: int = -1
8485
_params: tuple = ()
8586

8687
def __init__(self, database: DataBase, db_name: str = "", result_dict: bool = True, print_errors: bool = False) -> None:
8788
self._conn = database.connect(db_name)
8889
self._print_errors = print_errors
90+
self._set_row_factory(result_dict)
91+
self._cur = self._conn.cursor()
92+
93+
def _set_row_factory(self, result_dict: bool = True):
94+
self._result_dict = result_dict
8995
# self._conn.row_factory = sqlite3.Row
90-
if result_dict:
96+
if self._result_dict:
9197
self._conn.row_factory = lambda c, r: dict(
9298
[(col[0], r[idx]) for idx, col in enumerate(c.description)]
9399
)
94-
self._cur = self._conn.cursor()
95100

96101
def query(self, sql: str = "", params=(), fetch=2, column=0):
97102
if fetch == 2:

0 commit comments

Comments
 (0)