From 51a7052b36685373eceae804a51c5e6ec715e715 Mon Sep 17 00:00:00 2001 From: Matteo Campinoti Date: Tue, 12 Nov 2024 09:52:21 +0100 Subject: [PATCH] database.files_db:FilesDB - add init parameters to check version and initialization --- acacore/database/files_db.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/acacore/database/files_db.py b/acacore/database/files_db.py index 0d98ccd..81d1077 100644 --- a/acacore/database/files_db.py +++ b/acacore/database/files_db.py @@ -50,6 +50,8 @@ def __init__( detect_types: int = 0, isolation_level: str | None = "DEFERRED", check_same_thread: bool = True, + check_initialisation: bool = False, + check_version: bool = True, cached_statements: int = 100, ) -> None: super().__init__( @@ -157,7 +159,10 @@ def __init__( self.metadata: KeysTable[Metadata] = KeysTable(self.connection, Metadata, "metadata") - if self.is_initialised(): + if (check_initialisation or check_version) and not self.is_initialised(): + raise DatabaseError("Database is not initialized") + + if check_version and self.is_initialised(): is_latest(self.connection, raise_on_difference=True) def upgrade(self):