fixed bug of non closed database file

This commit is contained in:
Guillaume Raffy 2022-02-16 17:47:01 +01:00
parent 45f0a397a3
commit 57fa689015
1 changed files with 2 additions and 2 deletions

View File

@ -95,8 +95,8 @@ class SqlFile(ISqlDatabaseBackend):
# If set False, the returned connection may be shared across multiple threads. When using multiple threads with the same connection writing operations should be serialized by the user to avoid data corruption # If set False, the returned connection may be shared across multiple threads. When using multiple threads with the same connection writing operations should be serialized by the user to avoid data corruption
# I hope it's safe here but I'm not 100% sure though. Anyway, if the database gets corrupt, it not a big deal since this memory resident database gets reconstructed from the sql file... # I hope it's safe here but I'm not 100% sure though. Anyway, if the database gets corrupt, it not a big deal since this memory resident database gets reconstructed from the sql file...
self._con = sqlite3.connect(sqlite_db_path, check_same_thread=check_same_thread) self._con = sqlite3.connect(sqlite_db_path, check_same_thread=check_same_thread)
f = open(self._sql_file_path, 'r') with open(self._sql_file_path, 'r') as f:
sql = f.read() # watch out for built-in `str` sql = f.read() # watch out for built-in `str`
# print(sql) # print(sql)
self._cur = self._con.cursor() self._cur = self._con.cursor()
# print(mysql_to_sqlite(sql)) # print(mysql_to_sqlite(sql))