Commit 82f3871a authored by Kevin Morris's avatar Kevin Morris
Browse files

Support SQLAlchemy 1.4 URL.create recommendation



This fixes a deprecating warning when using SQLAlchemy 1.4.

Signed-off-by: Kevin Morris's avatarKevin Morris <kevr@0cost.org>
parent 81856f3b
......@@ -6,3 +6,4 @@ include = aurweb/*
fail_under = 85
exclude_lines =
if __name__ == .__main__.:
pragma: no cover
......@@ -16,9 +16,18 @@ def get_sqlalchemy_url():
Build an SQLAlchemy for use with create_engine based on the aurweb configuration.
"""
import sqlalchemy
constructor = sqlalchemy.engine.url.URL
parts = sqlalchemy.__version__.split('.')
major = int(parts[0])
minor = int(parts[1])
if major == 1 and minor >= 4: # pragma: no cover
constructor = sqlalchemy.engine.url.URL.create
aur_db_backend = aurweb.config.get('database', 'backend')
if aur_db_backend == 'mysql':
return sqlalchemy.engine.url.URL(
return constructor(
'mysql+mysqlconnector',
username=aurweb.config.get('database', 'user'),
password=aurweb.config.get('database', 'password'),
......@@ -29,7 +38,7 @@ def get_sqlalchemy_url():
},
)
elif aur_db_backend == 'sqlite':
return sqlalchemy.engine.url.URL(
return constructor(
'sqlite',
database=aurweb.config.get('database', 'name'),
)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment