File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed
Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -170,8 +170,10 @@ def create_connection(
170170 connection = RESOURCE_METAS [resource_arn ].connection_maker ( # type: ignore
171171 database , ** connection_kwargs
172172 )
173- if hasattr ( connection , 'database' ): # pragma: no cover
173+ try :
174174 connection .database = database
175+ except AttributeError : # pragma: no cover
176+ pass # for psycopg2
175177 return connection
176178
177179
@@ -210,12 +212,12 @@ def get_resource(
210212 else :
211213 connection = get_connection (transaction_id )
212214 if database :
213- if hasattr ( connection , 'database' ): # pragma: no cover
215+ try :
214216 connected_database : Optional [str ] = connection .database
215- else :
216- connected_database = connection .get_dsn_parameters ()[
217+ except AttributeError : # pragma: no cover
218+ connected_database = connection .get_dsn_parameters ()[ # for psycopg2
217219 'dbname'
218- ] # pragma: no cover
220+ ]
219221 if database != connected_database : # pragma: no cover
220222 raise BadRequestException (
221223 'Database name is not the same as when transaction was created'
You can’t perform that action at this time.
0 commit comments