pony icon indicating copy to clipboard operation
pony copied to clipboard

Feature request: support database connection URLs

Open fluffy-critter opened this issue 6 years ago • 3 comments

Some application runtimes such as Heroku only provide your database connection in the form of a URL provided at deployment time. It would be nice if PonyORM supported these URLs directly.

An example URL is in the form:

postgres://username:password@hostname:port/db-name

urllib.parse.urlparse gets us most of the way there pretty easily, but it would be nice if PonyORM could apply domain-specific knowledge to do it end-to-end. In particular, handling the various fiddly cases of no port present and stripping out the initial / from the path to get db-name would be nice.

fluffy-critter avatar Oct 13 '18 21:10 fluffy-critter

Oh, it looks like this could also be configured using:

db.connect(provider='postgres', dsn=os.environ['DATABASE_URL'])

It would still be swell if that could be simplified to just:

db.connect(url=os.environ['DATABASE_URL'])

though. :)

fluffy-critter avatar Oct 13 '18 21:10 fluffy-critter

While the feature is not realized, this snippet can help someone to configure Pony-powered app more easily: https://gist.github.com/Melevir/010881ef7c056ba118aca711d9a794c3

Melevir avatar Feb 15 '21 06:02 Melevir

Just hit this deploying an app to heroku.

AstraLuma avatar Dec 16 '21 18:12 AstraLuma