Skip to content

Conversation

dvhthomas
Copy link

In order to upstream the fix in the sqlite-utils repo (simonw/sqlite-utils#110) the version dependency needs to be bumped.

In order to upstream the fix in the sqlite-utils repo (simonw/sqlite-utils#110) the version dependency needs to be bumped.
@simonw
Copy link
Owner

simonw commented May 28, 2020

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

@simonw
Copy link
Owner

simonw commented May 28, 2020

Here's that comment in the code:

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)

It looks like I fixed that in simonw/sqlite-utils#94 - which shipped in sqlite-utils 2.4.3: https://sqlite-utils.readthedocs.io/en/stable/changelog.html#v2-4-3

simonw added a commit that referenced this pull request May 28, 2020
@simonw simonw closed this in aa288d8 May 28, 2020
@simonw
Copy link
Owner

simonw commented May 28, 2020

Thanks for this - I just released 1.2 with this fix: https://github.com/simonw/db-to-sqlite/releases/tag/1.2

@dvhthomas
Copy link
Author

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....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants