File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ('\\ ' , '/' ),
Original file line number Diff line number Diff line change 77#
88##########################################################################
99
10+ import re
11+
1012from sqlalchemy import create_engine , inspect
1113
1214
@@ -15,9 +17,11 @@ 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://" ,
23+ database_uri , count = 1
24+ )
2125 engine = create_engine (database_uri )
2226 try :
2327 connection = engine .connect ()
You can’t perform that action at this time.
0 commit comments