The clojure.java.jdbc library accepts connection parameters as URLs, but Korma assumes it's always a map.
You may well be able to get away with:
(default-connection (System/getenv "DATABASE_URL"))
Which will skip the pooling and pass the JDBC URL straight to clojure.java.jdbc. It would be nice if some of the internals of clojure.java.jdbc were opened up, as it seems to have all the logic for parsing the URL and guessing the correct driver class.
Thanks for the tip. I added the above call followed by another call to korma.config/merge-defaults (which incidentally doesn't actually merge the defaults) and got it working.
The heavy reliance upon atoms makes me uneasy, but this is a usable workaround for the time being. Thanks again.
Up vote this one
I've been thinking about htis a little, as well as thinking about other, similar issues.
I'm considering if the best thing is to just eliminate the Korma db-spec-creation altogether.
I took a brief look at java.jdbc, this line in particular shows just how many different types of specs are supported by java.jdbc. At first glance it seems that all the Korma layer around it is doing is stifling it, not offering much (any?) benefit over it.
I still want to spend some more time considering this from more angles, so ideas are welcome.
Would love to see this (passing a connection URL) implemented.
korma-0.3.0-RC1 includes changes to help with this. Your feedback is needed to help make the API ideal for the most people.
Does that mean that passing the connection URL is already implemented? For me that would be sufficient.
I used (db/default-connection (System/getenv "DATABASE_URL")) which worked fine for me.
DATABASE_URL = "postgresql://postgres:@localhost:5432/paperthin"
I would however expect that something like (defdb mydb DATABASE_URL) should work so I also get the pooling.
Up! Support for DATABASE_URL in Korma would be nice since e.g. Heroku Posgresql uses it.
Support for :connection-uri is already in master (527565d) and will be included in the next release.