Create target SQLite database before copying when restoring SQLite database

Closes #13795
(grafted from cf99ddf9358a6c1e05c5e17bfe9d41fe63b29c20)

--HG--
branch : 7.0
This commit is contained in:
Cédric Krier
2025-01-05 16:15:17 +01:00
parent 9df7de274a
commit 860e42e0c6
+9
View File
@@ -156,6 +156,15 @@ def _sqlite_copy(file_, restore=False):
or (not restore and os.path.exists(file_))):
return False
if restore:
database = backend.Database()
database.connect()
connection = database.get_connection(autocommit=True)
try:
database.create(connection, DB_NAME)
finally:
database.put_connection(connection, True)
with Transaction().start(DB_NAME, 0) as transaction, \
sqlite.connect(file_) as conn2:
conn1 = transaction.connection