[Ur] PATCH: add an URWEB_PQ_CON environment variable to override PostgreSQL connection string

austin seipp as at hacks.yi.org
Sat Sep 24 00:13:58 EDT 2011


The following changeset implements a very simple patch to the
PostgreSQL backend that lets you override the compiled-in '-db' option
at runtime with the URWEB_PQ_CON environment variable:

https://bitbucket.org/thoughtpolice/urweb/changeset/173d3cdc5bf9

It's on the 'psql-env-var' branch as you can see here:

https://bitbucket.org/thoughtpolice/urweb/changesets

My motivation for this is so I could get an Ur/Web app more easily
running on Heroku, without recompilation, using Postgres. Heroku uses
environment variables to specify such DB connection options, so this
seemed like a natural solution.

I'm not terribly interested in doing this for MySQL, but if someone
wants it, I guess it could be done somehow.

I mean, technically, Heroku uses a URI to specify the database
connection information (like
'postgres://username:password@ec2-host.com/dbname' ,) and a lot of
other apps have such vaguely JDBC-ish connection string formats, but I
couldn't find a free, stable, standalone C URI parser that was MIT/BSD
licensed to include in the runtime, and figured this was a good enough
solution for the time being. But if someone is interested in MySQL and
can think of how it should look, I may be willing to add it.

-- 
Regards,
Austin



More information about the Ur mailing list