Suppress SQLAlchemy warnings for DELETE statements in Database.py

This commit is contained in:
Théophile Diot 2024-11-12 15:52:58 +01:00
parent 444961ec99
commit c6d5061cd4
No known key found for this signature in database
GPG key ID: FA995104A0BA376A

View file

@ -18,6 +18,7 @@ from threading import Lock
from typing import Any, Dict, List, Literal, Optional, Set, Tuple, Union
from time import sleep
from uuid import uuid4
from warnings import filterwarnings
from model import (
Base,
@ -56,6 +57,7 @@ from sqlalchemy.exc import (
IntegrityError,
OperationalError,
ProgrammingError,
SAWarning,
SQLAlchemyError,
)
from sqlalchemy.orm import scoped_session, sessionmaker
@ -75,6 +77,9 @@ def set_sqlite_pragma(dbapi_connection, _):
cursor.close()
filterwarnings("ignore", category=SAWarning, message="DELETE statement on table .* expected to delete")
class Database:
DB_STRING_RX = re_compile(r"^(?P<database>(mariadb|mysql)(\+pymysql)?|sqlite(\+pysqlite)?|postgresql(\+psycopg)?):/+(?P<path>/[^\s]+)")
READONLY_ERROR = ("readonly", "read-only", "command denied", "Access denied")