Closed dvhthomas closed 4 years ago
That test failure is from this: https://travis-ci.com/github/simonw/db-to-sqlite/jobs/341173396
@all_databases
def test_db_to_sqlite(connection, tmpdir, cli_runner):
db_path = str(tmpdir / "test.db")
cli_runner([connection, db_path, "--all"])
db = sqlite_utils.Database(db_path)
assert {"categories", "products", "vendors"} == set(db.table_names())
> assert [
# Slight oddity: vendor_id comes out as a string even though MySQL
# defined it as an integer because sqlite-utils treats mixed
# integer + null as a string type, not an integer type
{"id": 1, "name": "Bobcat Statue", "cat_id": 1, "vendor_id": "1"},
{"id": 2, "name": "Yoga Scarf", "cat_id": 1, "vendor_id": None},
] == list(db["products"].rows)
E AssertionError: assert [{'cat_id': 1...or_id': None}] == [{'cat_id': 1,...or_id': None}]
E At index 0 diff: {'id': 1, 'name': 'Bobcat Statue', 'cat_id': 1, 'vendor_id': '1'} != {'id': 1, 'name': 'Bobcat Statue', 'cat_id': 1, 'vendor_id': 1}
E Use -v to get the full diff
Here's that comment in the code:
It looks like I fixed that in https://github.com/simonw/sqlite-utils/issues/94 - which shipped in sqlite-utils 2.4.3: https://sqlite-utils.readthedocs.io/en/stable/changelog.html#v2-4-3
Thanks for this - I just released 1.2 with this fix: https://github.com/simonw/db-to-sqlite/releases/tag/1.2
And now I can happily clone a Postgres database to SQLite with a one-liner. Thank you! We plan on using your sqlite tools and Datasette for an open data project around infrastructure stimulus spending for at least one U.S. state.
Fiddling with Geometry (PostGIS) data types next....
In order to upstream the fix in the sqlite-utils repo (https://github.com/simonw/sqlite-utils/issues/110) the version dependency needs to be bumped.