dev: 支持清空数据库
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user