Untitled
unknown
plain_text
a year ago
864 B
14
Indexable
from sqlalchemy import select
from src.database.models.Metadata import MetadataModel
def is_db_locked(db):
try:
metadata = db.scalar(select(MetadataModel))
except Exception:
# if we are here, it only means that there was no metadata table
# which means that the upgrade was not executed yet
# therefore, we ignore the error and return false
return False
return metadata.is_db_locked if metadata is not None else False
def lock_db(db):
try:
metadata = db.scalar(select(MetadataModel))
metadata.is_db_locked = True
db.commit()
except Exception:
pass
def unlock_db(db):
try:
metadata = db.scalar(select(MetadataModel))
metadata.is_db_locked = False
db.commit()
except Exception:
pass
Editor is loading...
Leave a Comment