Coverage for src/sqlqb/sqlite/__init__.py: 100%
20 statements
« prev ^ index » next coverage.py v7.14.1, created at 2026-06-20 15:56 +0200
« prev ^ index » next coverage.py v7.14.1, created at 2026-06-20 15:56 +0200
1import sqlite3
3from sqlqb import Select as _Select
6class Select(_Select):
7 def __init__(self, connection, *columns):
8 super().__init__(*columns)
9 self._connection = connection
11 def execute(self) -> sqlite3.Cursor:
12 return self._connection.execute(self.sql, self.params)
14 def fetchone(self):
15 return self.execute().fetchone()
17 def fetchall(self) -> list:
18 return self.execute().fetchall()
21class Connection(sqlite3.Connection):
22 def __init__(self, *args, **kwargs):
23 super().__init__(*args, **kwargs)
24 self.row_factory = lambda cursor, row: dict(zip([col[0] for col in cursor.description], row))
26 def Select(self, *args, **kwargs) -> Select:
27 return Select(self, *args, **kwargs)
30def connect(database, **kwargs) -> Connection:
31 return sqlite3.connect(database, factory=Connection, **kwargs)