mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-24 09:54:31 +02:00
Hack to support reuse of memory command, closes #643
This commit is contained in:
parent
4c2628873c
commit
8906f57740
4 changed files with 65 additions and 2 deletions
|
|
@ -325,6 +325,8 @@ class Database:
|
|||
execute_plugins: bool = True,
|
||||
strict: bool = False,
|
||||
):
|
||||
self.memory_name = None
|
||||
self.memory = False
|
||||
assert (filename_or_conn is not None and (not memory and not memory_name)) or (
|
||||
filename_or_conn is None and (memory or memory_name)
|
||||
), "Either specify a filename_or_conn or pass memory=True"
|
||||
|
|
@ -335,8 +337,11 @@ class Database:
|
|||
uri=True,
|
||||
check_same_thread=False,
|
||||
)
|
||||
self.memory = True
|
||||
self.memory_name = memory_name
|
||||
elif memory or filename_or_conn == ":memory:":
|
||||
self.conn = sqlite3.connect(":memory:")
|
||||
self.memory = True
|
||||
elif isinstance(filename_or_conn, (str, pathlib.Path)):
|
||||
if recreate and os.path.exists(filename_or_conn):
|
||||
try:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue