Connection parameters as URLs is broken #62

Closed
technomancy opened this Issue May 14, 2012 · 13 comments

8 participants

@technomancy

The clojure.java.jdbc library accepts connection parameters as URLs, but Korma assumes it's always a map.

@hotwoofy

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.

@technomancy

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.

@huahaiy

Up vote this one

@bitemyapp
korma member

Upvote here.

@AlexBaranosky
korma member

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.
https://github.com/clojure/java.jdbc/blob/master/src/main/clojure/clojure/java/jdbc.clj#L140

I still want to spend some more time considering this from more angles, so ideas are welcome.

@mrijk

Would love to see this (passing a connection URL) implemented.

@AlexBaranosky
korma member
@AlexBaranosky
korma member

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.

@mrijk

Does that mean that passing the connection URL is already implemented? For me that would be sufficient.

@AlexBaranosky
korma member
@mrijk

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.

@ykarikos

Up! Support for DATABASE_URL in Korma would be nice since e.g. Heroku Posgresql uses it.

@immoh
korma member

Support for :connection-uri is already in master (527565d) and will be included in the next release.

@immoh immoh added this to the 0.5.0 milestone Sep 25, 2015
@immoh immoh closed this Sep 25, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment