4 ms·
I'll try to address your concerns, but keep in mind: this is a very new project. 1. When you "exec" a query, all I'm really doing is compiling the query map in
by taylorlapeyre 12y ago
I'll try to address your concerns, but keep in mind: this is a very new project.
1. When you "exec" a query, all I'm really doing is compiling the query map into an SQL statement and passing it into java.jdbc[1] with the database configuration that is given. This database config can be stored as a regular Clojure map in a config namespace in your project or however you wish. To answer your question, yes, at the moment java.jdbc is called for each query that is executed and I can only assume that that means that a new connection is made. Obviously there is room for improvement here, which will be addressed in the future.
2. I've provided a thorough specification for what makes a Clojure map a "query map" in the SPEC file[2]. Before any query map is compiled into SQL, it gets validated by a function that ensures that it meets the specification. If not, it throws an error.
Hopefully this answers some of your concerns! Like I said, this is a new project that I made for fun and for personal use. I plan on working on it for a long time, and I'm sure that many things will be improved! I hope that others find it useful (or at least interesting) as well.
[1]: https://github.com/clojure/java.jdbc/ https://github.com/clojure/java.jdbc/
[2]: https://github.com/taylorlapeyre/oj/blob/master/doc/SPEC https://github.com/taylorlapeyre/oj/blob/master/doc/SPEC
- mschaef 12y agoRegarding point 1, java.jdbc can accept a variety of types of connection maps. The simplest scenario is you pass in a map that contains the connection information, and you get a new connection and transaction for each call. However, you can also pass in live connections/transactions that can be reused. The with-db-transaction form is one way to accomplish this. It's really pretty flexible. (And btw, your library looks really quite good! I'm glad people are trying to address the issue of generating SQL within Clojure.)