Skip to content

Upgrade for compatibility with SQLAlchemy 2 #46

@jesus-hergueta

Description

@jesus-hergueta

Hi.

I'm trying to use the tool to export a Dockerized PostgresDB to a SQLite DB in order to read it with Datasette.

But when I try to run the command get the following error:

python3 -m venv venv
source venv/bin/activate
pip install db-to-sqlite
pip install 'db-to-sqlite[postgresql]'
And then:

❯ db-to-sqlite "postgresql://user:password@localhost:8080/my_db" demo.db \
    --all \
    --postgres-schema public
Traceback (most recent call last):
  File "/root/datasette/venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1410, in execute
    meth = statement._execute_on_connection
AttributeError: 'str' object has no attribute '_execute_on_connection'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/root/datasette/venv/bin/db-to-sqlite", line 8, in <module>
    sys.exit(cli())
  File "/root/datasette/venv/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/root/datasette/venv/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/root/datasette/venv/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/root/datasette/venv/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/root/datasette/venv/lib/python3.10/site-packages/db_to_sqlite/cli.py", line 112, in cli
    results = db_conn.execute("select * from {}".format(table_quoted))
  File "/root/datasette/venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1412, in execute
    raise exc.ObjectNotExecutableError(statement) from err
sqlalchemy.exc.ObjectNotExecutableError: Not an executable object: 'select * from "some_table"'

I'm using PG 13.9-1.pgdg110+1 in Docker Desktop 4.16.3 (96739).
Python 3.10.6
Ubuntu 22.04.1 LTS with WSL2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions