@@ -107,7 +107,7 @@ def __init__(
107
107
self ,
108
108
provider_def : dict ,
109
109
driver_name : str ,
110
- extra_conn_args : Optional [dict ]
110
+ extra_conn_args : Optional [dict ] = {}
111
111
):
112
112
"""
113
113
GenericSQLProvider Class constructor
@@ -143,9 +143,7 @@ def __init__(
143
143
LOGGER .debug (f'Configured Storage CRS: { self .storage_crs } ' )
144
144
145
145
# Read table information from database
146
- options = None
147
- if provider_def .get ('options' ):
148
- options = provider_def ['options' ]
146
+ options = provider_def .get ('options' , {})
149
147
self ._store_db_parameters (provider_def ['data' ], options )
150
148
self ._engine = get_engine (
151
149
driver_name ,
@@ -154,7 +152,7 @@ def __init__(
154
152
self .db_name ,
155
153
self .db_user ,
156
154
self ._db_password ,
157
- ** ( self .db_options or {}) | ( extra_conn_args or {})
155
+ ** self .db_options | extra_conn_args
158
156
)
159
157
self .table_model = get_table_model (
160
158
self .table , self .id_field , self .db_search_path , self ._engine
@@ -443,7 +441,11 @@ def _store_db_parameters(self, parameters, options):
443
441
# reflecting the table definition from the DB
444
442
self .db_search_path = tuple (parameters .get ('search_path' , ['public' ]))
445
443
self ._db_password = parameters .get ('password' )
446
- self .db_options = options
444
+ self .db_options = {
445
+ k : v
446
+ for k , v in options .items ()
447
+ if not isinstance (v , dict )
448
+ }
447
449
448
450
def _sqlalchemy_to_feature (self , item , crs_transform_out = None ):
449
451
feature = {'type' : 'Feature' }
@@ -608,7 +610,7 @@ def get_engine(
608
610
database : str ,
609
611
user : str ,
610
612
password : str ,
611
- ** connection_options
613
+ ** connect_args
612
614
):
613
615
"""Create SQL Alchemy engine."""
614
616
conn_str = URL .create (
@@ -619,11 +621,8 @@ def get_engine(
619
621
port = int (port ),
620
622
database = database
621
623
)
622
- conn_args = {
623
- ** connection_options
624
- }
625
624
engine = create_engine (
626
- conn_str , connect_args = conn_args , pool_pre_ping = True
625
+ conn_str , connect_args = connect_args , pool_pre_ping = True
627
626
)
628
627
return engine
629
628
0 commit comments