minor linting.

This commit is contained in:
voussoir 2025-03-24 22:15:22 -07:00
parent 8584dc5e7f
commit d9a5d0811d

View file

@ -173,6 +173,7 @@ class Database(metaclass=abc.ABCMeta):
''' '''
if isinstance(path, pathclass.Path): if isinstance(path, pathclass.Path):
path = path.absolute_path path = path.absolute_path
if path == ':memory:': if path == ':memory:':
sql_read = sqlite3.connect(f'file:{self._memdb_random}?mode=memory&cache=shared', uri=True) sql_read = sqlite3.connect(f'file:{self._memdb_random}?mode=memory&cache=shared', uri=True)
sql_read.row_factory = sqlite3.Row sql_read.row_factory = sqlite3.Row
@ -180,6 +181,7 @@ class Database(metaclass=abc.ABCMeta):
log.debug('Connecting to sqlite file "%s".', path) log.debug('Connecting to sqlite file "%s".', path)
sql_read = sqlite3.connect(f'file:{path}?mode=ro', uri=True) sql_read = sqlite3.connect(f'file:{path}?mode=ro', uri=True)
sql_read.row_factory = sqlite3.Row sql_read.row_factory = sqlite3.Row
return sql_read return sql_read
def _make_sqlite_write_connection(self, path): def _make_sqlite_write_connection(self, path):
@ -193,6 +195,7 @@ class Database(metaclass=abc.ABCMeta):
log.debug('Connecting to sqlite file "%s".', path) log.debug('Connecting to sqlite file "%s".', path)
sql_write = sqlite3.connect(path) sql_write = sqlite3.connect(path)
sql_write.row_factory = sqlite3.Row sql_write.row_factory = sqlite3.Row
return sql_write return sql_write
def assert_no_transaction(self) -> None: def assert_no_transaction(self) -> None:
@ -331,12 +334,11 @@ class Database(metaclass=abc.ABCMeta):
lines = (line for line in lines if line) lines = (line for line in lines if line)
cur = self.sql_write.cursor() cur = self.sql_write.cursor()
for line in lines: for line in lines:
log.loud(line)
cur.execute(line) cur.execute(line)
def exists(self, query, bindings=None) -> bool: def exists(self, query, bindings=None) -> bool:
''' '''
query should be a SELECT query. query should be a SELECT query, usually `SELECT 1 FROM table WHERE`.
Returns True if at least one row was found, False if no rows found. Returns True if at least one row was found, False if no rows found.
''' '''