Skip to content

Commit

Permalink
database.files_db:FileDB - do not init automatically, add parameter t…
Browse files Browse the repository at this point in the history
…o check if database is initialized and raise an error if not
  • Loading branch information
MatteoCampinoti94 committed Nov 21, 2024
1 parent d418aed commit a39de3d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions acacore/database/files_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from os import PathLike
from pathlib import Path
from sqlite3 import Connection
from sqlite3 import DatabaseError
from typing import Type
from uuid import UUID

Expand Down Expand Up @@ -52,6 +53,7 @@ def __init__(
cached_statements: int = 100,
uri: bool = False,
check_version: bool = True,
check_initialisation: bool = False,
) -> None:
"""
A class that handles the SQLite database used by AArhus City Archives to process data archives.
Expand Down Expand Up @@ -203,13 +205,13 @@ def __init__(
],
)

if self.is_initialised(check_views=False, check_indices=False):
if check_version:
from acacore.database.upgrade import is_latest
if check_initialisation and not self.is_initialised(check_views=False, check_indices=False):
raise DatabaseError("Database is not initialised")

is_latest(self, raise_on_difference=True)
else:
self.init()
if check_version and self.is_initialised():
from acacore.database.upgrade import is_latest

is_latest(self, raise_on_difference=True)

def is_initialised(self, *, check_views: bool = True, check_indices: bool = True) -> bool:
"""
Expand Down

0 comments on commit a39de3d

Please sign in to comment.