See comments in code
This commit is contained in:
parent
4fde0e8efd
commit
1196424bbd
|
@ -35,10 +35,12 @@ class SQLiteDatabaseRepository(AbstractDatabaseRepository):
|
|||
self.conn = sqlite3.connect(self.path)
|
||||
self.cursor = self.conn.cursor()
|
||||
|
||||
def _namedtuple_factory(cursor, row):
|
||||
fields = [column[0] for column in cursor.description]
|
||||
def _namedtuple_factory(cursor, row, raw_tuples):
|
||||
# TODO: fix that. Here causes errors. Or remove namedtyples and use normal index tuple. Also, row - is cursor
|
||||
# Good luck
|
||||
fields = [column[0] for column in row.description]
|
||||
cls = namedtuple("Row", fields)
|
||||
return cls._make(row)
|
||||
return cls._make(raw_tuples)
|
||||
|
||||
def create_tables(self) -> None:
|
||||
"""Init tables in database"""
|
||||
|
@ -50,7 +52,8 @@ class SQLiteDatabaseRepository(AbstractDatabaseRepository):
|
|||
def get_user_by_id(self, user_id: str) -> User:
|
||||
"""Get user by user id"""
|
||||
|
||||
self.conn.row_factory = self._namedtuple_factory
|
||||
self.conn.row_factory = self._namedtuple_factory # Error here, not use named
|
||||
|
||||
self.cur_userdata = self.conn.execute(
|
||||
"SELECT user_id AS user_id, first_name AS first_name, last_name AS last_name, username AS username, avatar_hash AS avatar_hash FROM platforms_users WHERE user_id = (?)",
|
||||
(user_id,)
|
||||
|
|
Reference in a new issue