From 3de920f54b0fb7a2251bd9cbdd4a2477dd871d2e Mon Sep 17 00:00:00 2001 From: Infinidoge Date: Tue, 31 Dec 2024 18:09:11 -0500 Subject: [PATCH] add repr to db rows --- nomen/db.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nomen/db.py b/nomen/db.py index c9baabc..6eb708d 100644 --- a/nomen/db.py +++ b/nomen/db.py @@ -96,6 +96,11 @@ aiosqlite.Connection.fetch_exists = fetch_exists 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): log.debug(f"Connecting to {db_file}") db = await aiosqlite.connect(db_file) @@ -108,7 +113,7 @@ async def setup_db(db_file): """) log.debug("Setting row factory") - db.row_factory = sqlite3.Row + db.row_factory = Row log.debug("Adding contains function") await db.create_function("contains", 3, contains, deterministic=True)