simonw / db-to-sqlite

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

Can't load plugin: sqlalchemy.dialects:postgres #34

Closed simonw closed 3 years ago

simonw commented 3 years ago

Getting this error running the Heroku example from the README:

    $ db-to-sqlite $(heroku config --app myappname | grep HEROKU_POSTG | cut -d: -f 2-) \

https://stackoverflow.com/a/66794960/6083 explains why:

SQLAlchemy 1.4 removed the deprecated postgres dialect name, the name postgresql must be used instead now. The dialect is the part before the :// in the URL. SQLAlchemy 1.3 and earlier showed a deprecation warning but still accepted it.

To fix this, rename postgres:// in the URL to postgresql://.

simonw commented 3 years ago

I'm going to teach this tool to replace postgres:// with postgresql://.

dogweather commented 2 years ago

I'm going to teach this tool to replace postgres:// with postgresql://.

Yes, please! I've discovered that other tools auto-generate postgres:// URLs, such as Heroku and Render. Everyone on those platforms is wondering why their app suddenly stopped working.

If I was King: I'd

be conservative in what you send, be liberal in what you accept

and allow both. Because: there's no real difference between the two. There isn't some other incompatible DBMS called postgres that we need to distinguish.

https://en.wikipedia.org/wiki/Robustness_principle

simonw commented 2 years ago

I implemented that fix in https://github.com/simonw/db-to-sqlite/commit/06495ce3b6e27072c59e1bddfb446ff475e4d277 so you should be seeing both of those options work, provided you have version 1.4.

HaKuNamaTT-ZZH commented 2 years ago

Hi, I am using sqlalchemy to reach Cassandra with reference to https://www.cdata.com/kb/tech/cassandra-python-sqlalchemy.rst But the url is not right, the raised error is similar to your error msg: sqlalchemy.exc.NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:cassandra

What should I do... The create_engine function's annotation did not mention Cassandra at all