diff --git a/.github/workflows/unittests-mysql.yaml b/.github/workflows/unittests-mysql.yaml index ca6b2afa..a6a96e87 100644 --- a/.github/workflows/unittests-mysql.yaml +++ b/.github/workflows/unittests-mysql.yaml @@ -1,4 +1,4 @@ -name: Bitcoinlib Tests Ubuntu MySQL +name: Bitcoinlib Tests Ubuntu - MySQL on: [push] jobs: diff --git a/bitcoinlib/db_cache.py b/bitcoinlib/db_cache.py index 98d9b7f3..124eb204 100644 --- a/bitcoinlib/db_cache.py +++ b/bitcoinlib/db_cache.py @@ -90,7 +90,8 @@ def __init__(self, db_uri=None): def drop_db(self): self.session.commit() - self.session.close_all() + self.session.close() + session.close_all_sessions() Base.metadata.drop_all(self.engine) diff --git a/tests/test_tools.py b/tests/test_tools.py index e3db1c84..dea88af0 100644 --- a/tests/test_tools.py +++ b/tests/test_tools.py @@ -45,10 +45,7 @@ def database_init(dbname=DATABASE_NAME): con.close() return 'postgresql://postgres:postgres@localhost:5432/' + dbname elif os.getenv('UNITTEST_DATABASE') == 'mysql': - try: - con = mysql.connector.connect(user='root', host='localhost') - except mysql.connector.errors.ProgrammingError: - con = mysql.connector.connect(user='user', host='localhost', password='password') + con = mysql.connector.connect(user='user', host='localhost', password='password') cur = con.cursor() cur.execute("DROP DATABASE IF EXISTS {}".format(dbname)) cur.execute("CREATE DATABASE {}".format(dbname))