From 97f0b71f5a2e8ed7d862f4ca43ea33b2000cd5b6 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Wed, 31 Aug 2022 03:30:01 +0300 Subject: Provide database port where relevant. --- qc_app/db_utils.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/qc_app/db_utils.py b/qc_app/db_utils.py index 239f45c..98f8332 100644 --- a/qc_app/db_utils.py +++ b/qc_app/db_utils.py @@ -11,10 +11,11 @@ def parse_db_url(db_url) -> Tuple: """ parsed_db = urlparse(db_url) return (parsed_db.hostname, parsed_db.username, - parsed_db.password, parsed_db.path[1:]) + parsed_db.password, parsed_db.path[1:], parsed_db.port) def database_connection(db_url: Optional[str] = None) -> mdb.Connection: """function to create db connector""" - host, user, passwd, db_name = parse_db_url(db_url or app.config["SQL_URI"]) - return mdb.connect(host, user, passwd, db_name) + host, user, passwd, db_name, db_port = parse_db_url( + db_url or app.config["SQL_URI"]) + return mdb.connect(host, user, passwd, db_name, port=(db_port or 3306)) -- cgit v1.2.3