simonw / db-to-sqlite

CLI tool for exporting tables or queries from any SQL database to a SQLite file
Apache License 2.0
370 stars 29 forks source link

MySQL tests fail after multiple runs #50

Open amoeba opened 1 year ago

amoeba commented 1 year ago

I noticed while running the tests locally that the MySQL tests started failing with an error (complete summary at the bottom):

MySQLdb.IntegrityError: (1062, "Duplicate entry '1' for key 'vendors.PRIMARY'")

I compared the setup blocks for MySQL and PostgreSQL and I see one difference is that the PostgreSQL block drops databases during setup while the MySQL block does not. @simonw do you test locally and have a setup that works for you? I'll submit a PR linked to this issue for how I worked around it.

Btw: I followed the README closely. I see that the tests on CI pass which I assume is because the databases are wiped on reach run.

Environment:

pytest output summary ``` rs.PRIMARY'") ERROR tests/test_docs.py::test_readme_contains_latest_help - MySQLdb.IntegrityError: (1062, "Duplicate entry '1' for key 'vendors.PRIMARY'") ERROR tests/test_fixtures.py::test_fixture_mysql - MySQLdb.IntegrityError: (1062, "Duplicate entry '1' for key 'vendors.PRIMARY'") ERROR tests/test_fixtures.py::test_fixture_postgresql - MySQLdb.IntegrityError: (1062, "Duplicate entry '1' for key 'vendors.PRIMARY'") ERROR tests/test_redact.py::test_redact[mysql://root@127.0.0.1:3306/test_db_to_sqlite] - MySQLdb.IntegrityError: (1062, "Duplicate entry '1' for key 'vendors.PRIMARY'") ERROR tests/test_redact.py::test_redact[postgresql://localhost/test_db_to_sqlite] - MySQLdb.IntegrityError: (1062, "Duplicate entry '1' for key 'vendors.PRIMARY'") ERROR tests/test_redact.py::test_redact[postgres://localhost/test_db_to_sqlite] - MySQLdb.IntegrityError: (1062, "Duplicate entry '1' for key 'vendors.PRIMARY'") =========================================================== 19 errors in 0.13s ============================================================ ```