|
33 | 33 | from datetime import timezone |
34 | 34 |
|
35 | 35 | import mock |
36 | | -import mysql.connector |
37 | 36 | import psycopg2 |
38 | 37 | import pytds |
39 | 38 | import sqlalchemy |
@@ -286,26 +285,22 @@ def temp_mysql_database(): |
286 | 285 | Exception: Any other exception encountered during the setup process. |
287 | 286 | """ |
288 | 287 | with MySqlContainer(init=True, dialect='pymysql') as mysql_container: |
289 | | - try: |
290 | | - # Make connection to temp database and create tmp table |
291 | | - engine = sqlalchemy.create_engine(mysql_container.get_connection_url()) |
292 | | - with engine.begin() as connection: |
293 | | - connection.execute( |
294 | | - sqlalchemy.text( |
295 | | - "CREATE TABLE tmp_table (value INTEGER, `rank` INTEGER);")) |
| 288 | + # Make connection to temp database and create tmp table |
| 289 | + engine = sqlalchemy.create_engine(mysql_container.get_connection_url()) |
| 290 | + with engine.begin() as connection: |
| 291 | + connection.execute( |
| 292 | + sqlalchemy.text( |
| 293 | + "CREATE TABLE tmp_table (value INTEGER, `rank` INTEGER);")) |
296 | 294 |
|
297 | | - # Construct the JDBC url for connections later on by tests |
298 | | - jdbc_url = ( |
299 | | - f"jdbc:mysql://{mysql_container.get_container_host_ip()}:" |
300 | | - f"{mysql_container.get_exposed_port(mysql_container.port)}/" |
301 | | - f"{mysql_container.dbname}?" |
302 | | - f"user={mysql_container.username}&" |
303 | | - f"password={mysql_container.password}") |
| 295 | + # Construct the JDBC url for connections later on by tests |
| 296 | + jdbc_url = ( |
| 297 | + f"jdbc:mysql://{mysql_container.get_container_host_ip()}:" |
| 298 | + f"{mysql_container.get_exposed_port(mysql_container.port)}/" |
| 299 | + f"{mysql_container.dbname}?" |
| 300 | + f"user={mysql_container.username}&" |
| 301 | + f"password={mysql_container.password}") |
304 | 302 |
|
305 | | - yield jdbc_url |
306 | | - except mysql.connector.Error as err: |
307 | | - logging.error("Error interacting with temporary MySQL DB: %s", err) |
308 | | - raise err |
| 303 | + yield jdbc_url |
309 | 304 |
|
310 | 305 |
|
311 | 306 | @contextlib.contextmanager |
|
0 commit comments