dev: 支持清空数据库

This commit is contained in:
Julian Freeman
2024-07-19 13:43:13 -04:00
parent 631127377a
commit 85b6456f87
3 changed files with 90 additions and 11 deletions

View File

@@ -255,6 +255,7 @@ def order(column: Column | str | int,
class Sqlite3Worker(object):
def __init__(self, db_name: str | PathLike[str] = ":memory:"):
self._db_name = db_name
self._conn = sqlite3.connect(db_name)
self._cursor = self._conn.cursor()
self._is_closed = False
@@ -262,6 +263,10 @@ class Sqlite3Worker(object):
def __del__(self):
self.close()
@property
def db_name(self) -> str:
return self._db_name
def close(self):
if self._is_closed is False:
self._cursor.close()