add repr to db rows

This commit is contained in:
Infinidoge 2024-12-31 18:09:11 -05:00
parent e0001625ae
commit 3de920f54b
Signed by: Infinidoge
SSH key fingerprint: SHA256:GT2StvPQMMfFHyiiFJymQxfTG/z6EWLJ6NWItf5K5sA

View file

@ -96,6 +96,11 @@ aiosqlite.Connection.fetch_exists = fetch_exists
aiosqlite.Connection.fetch_unpacked = fetch_unpacked aiosqlite.Connection.fetch_unpacked = fetch_unpacked
class Row(sqlite3.Row):
def __repr__(self):
return f"Row<{repr(dict(self))}>"
async def setup_db(db_file): async def setup_db(db_file):
log.debug(f"Connecting to {db_file}") log.debug(f"Connecting to {db_file}")
db = await aiosqlite.connect(db_file) db = await aiosqlite.connect(db_file)
@ -108,7 +113,7 @@ async def setup_db(db_file):
""") """)
log.debug("Setting row factory") log.debug("Setting row factory")
db.row_factory = sqlite3.Row db.row_factory = Row
log.debug("Adding contains function") log.debug("Adding contains function")
await db.create_function("contains", 3, contains, deterministic=True) await db.create_function("contains", 3, contains, deterministic=True)