Skip to content

Commit f34a5b3

Browse files
Fix the review comments.
1 parent 8d92361 commit f34a5b3

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

web/pgadmin/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,11 @@ def get_locale():
337337
##########################################################################
338338
if config.CONFIG_DATABASE_URI is not None and \
339339
len(config.CONFIG_DATABASE_URI) > 0:
340-
app.config['SQLALCHEMY_DATABASE_URI'] = config.CONFIG_DATABASE_URI
340+
_db_uri = re.sub(
341+
r"^postgres(ql)?://", "postgresql+psycopg://",
342+
config.CONFIG_DATABASE_URI, count=1
343+
)
344+
app.config['SQLALCHEMY_DATABASE_URI'] = _db_uri
341345
else:
342346
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///{0}?timeout={1}' \
343347
.format(config.SQLITE_PATH.replace('\\', '/'),

web/pgadmin/utils/check_external_config_db.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#
88
##########################################################################
99

10+
import re
11+
1012
from sqlalchemy import create_engine, inspect
1113

1214

@@ -15,9 +17,10 @@ def check_external_config_db(database_uri):
1517
Check if external config database exists if it
1618
is being used.
1719
"""
18-
if database_uri.startswith("postgresql://") or database_uri.startswith(
19-
"postgres://"):
20-
database_uri = database_uri.replace("://", "+psycopg://", 1)
20+
if database_uri.startswith(("postgresql://", "postgres://")):
21+
database_uri = re.sub(
22+
r"^postgres(ql)?://", "postgresql+psycopg://", database_uri, count=1
23+
)
2124
engine = create_engine(database_uri)
2225
try:
2326
connection = engine.connect()

0 commit comments

Comments
 (0)