dokku / dokku-postgres

a postgres plugin for dokku

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SQLAlchemy uses different convention for DATABASE_URL

JanRuettinger opened this issue · comments

dokku-postgres exposes the environment variable:
DATABASE_URL=postgres://lolipop:SOME_PASSWORD@dokku-postgres-lolipop:5432/lolipop.

However, SQLAlchemy expects (source):
DATABASE_URL=postgresql://scott:tiger@localhost:5432/mydatabase'

Notice the small difference in the name of the dialect postgres vs postgresql.
It would be beneficial to expose either a second env variable or offer flexibility to configure DATABASE_URL.

Where would be the best place to create a new modification of the DATABASE_URL env var? I was thinking of doing it in a predeploy script.

EDIT:
This issue starts to occur with SQLAlchemy 1.4. Versions before still accepted postgres as a dialect name. More info can be found in this SO post. Heroku fixed it by introducing a new env variable called SQLALCHEMY_DATABASE_URI.

You can already change the scheme used for the DATABASE_URL by changing the PLUGIN_SCHEME config var in /var/lib/dokku/plugins/enabled/postgres/config.

Great! Maybe it's worth mentioning in the readme.

Linking docs show how to specify an alternative scheme.

The section you linked to doesn't show how to use the PLUGIN_SCHEME config var. I think that's missing.

The actual preferred method is POSTGRES_DATABASE_SCHEME, not PLUGIN_SCHEME. The latter is an internal construct and can change anytime, whereas the former is something specific to this plugin.

If you set PLUGIN_SCHEME, that applies to every datastore plugin, not just this one.