- If the
DATABASE_URL
starts with postgres://
(Heroku's default), it replaces it with the correct format, postgresql+psycopg2://
, making the URI compatible with SQLAlchemy.
Instead of manually replacing the URI, you can use libraries like dj-database-url
to parse and adapt the DATABASE_URL
for different frameworks or drivers. However, the manual approach is straightforward and works well for most cases.