From 860e42e0c6eb7ca16756b5e57b44edf0356b5a69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 5 Jan 2025 16:15:17 +0100 Subject: [PATCH] Create target SQLite database before copying when restoring SQLite database Closes #13795 (grafted from cf99ddf9358a6c1e05c5e17bfe9d41fe63b29c20) --HG-- branch : 7.0 --- trytond/trytond/tests/test_tryton.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/trytond/trytond/tests/test_tryton.py b/trytond/trytond/tests/test_tryton.py index b8dc2d9a99..7fbc338a9c 100644 --- a/trytond/trytond/tests/test_tryton.py +++ b/trytond/trytond/tests/test_tryton.py @@ -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