diff --git a/src/common/db/Database.py b/src/common/db/Database.py index 0aae7bbdba..c0911dce26 100644 --- a/src/common/db/Database.py +++ b/src/common/db/Database.py @@ -54,7 +54,7 @@ class Database: - DB_STRING_RX = re_compile(r"^(?P(mariadb|mysql)(\+pymysql)?|sqlite(\+pysqlite)?|postgresql):/+(?P/[^\s]+)") + DB_STRING_RX = re_compile(r"^(?P(mariadb|mysql)(\+pymysql)?|sqlite(\+pysqlite)?|postgresql(\+psycopg)?):/+(?P/[^\s]+)") def __init__( self, @@ -85,6 +85,10 @@ def __init__( sleep(1) else: db_path.parent.mkdir(parents=True, exist_ok=True) + elif match.group("database").startswith("m") and not match.group("database").endswith("+pymysql"): + sqlalchemy_string = sqlalchemy_string.replace(match.group("database"), f"{match.group('database')}+pymysql") # ? This is mandatory for alemic to work with mariadb and mysql + elif match.group("database").startswith("postgresql") and not match.group("database").endswith("+psycopg"): + sqlalchemy_string = sqlalchemy_string.replace(match.group("database"), f"{match.group('database')}+psycopg") # ? This is strongly recommended as psycopg is the new way to connect to postgresql self.database_uri = sqlalchemy_string error = False