Many libraries starting with clojure.java.jdbc and libraries that use clojure.java.jdbc internally expect a JDBC URI to connect to the database, but your environment might be giving you the database specs in a different format. to-jdbc-uri is designed to take the database credentials in any format and, as long as it's possible, generate a valid JDBC URI. Currently supported:
- PostgreSQL (Heroku, RedHat OpenShift and others)
Support for other formats, databases, environments is welcome.
The code in this library is actually trivial but if you need to perform this task and search for solutions you'll find lots of different snippets of code, some which work in some environments and not others. Even if you end up not using this library but copying and pasting the code it is better to have a canonical place for this code to exist.
project.clj include the dependency:
and then call it like this:
which will output:
It is safe to feed JDBC URIs to this library, they'll be left untouched. For more examples, you might want to look into the tests, which are very simple.
Note: to-jdbc-uri up to version 0.3.0 was not in the com.carouselapps group, from 0.4.0 it'll be in the
com.carouselapps groups. If you are using this jar, you can and should switch from
[to-jdbc-uri "0.3.0"] to
[com.carouselapps/to-jdbc-uri "0.4.1"] or the latest version.
- fork the project.
- Add support for your favorite database/environment/format/feature.
- Add tests for the new code you wrote.
- Make sure all tests pass, new and all.
- Push, commit and send a pull request. Note how urgently you need a new release.
v0.5.0 - 2015-12-22
v0.4.1 - 2015-11-03
- Corrected syntax for case when selected for PostgreSQL.
v0.4.0 - 2015-11-03
- Added support for RedHat OpenShift PostgreSQL URLs. Courtesy of Pradnyesh Sawant.
- Moved jar to the com.carouselapps group.
v0.3.0 - 2015-08-24
v0.2.0 - 2015-06-20
- Raise an exception when the URI is empty or blank.
- Started using Travis CI for continuous integration.
v0.1.0 - 2015-06-15
- Initial version supporting PostgreSQL (at least on Heroku).
Copyright © 2015 Carousel Apps, Ltd. All rights reserved.
Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.