pony
pony copied to clipboard
Feature request: support database connection URLs
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.
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. :)
While the feature is not realized, this snippet can help someone to configure Pony-powered app more easily: https://gist.github.com/Melevir/010881ef7c056ba118aca711d9a794c3
Just hit this deploying an app to heroku.