Hi, On 13 Aug., 14:51, jandot <jan.ae...@gmail.com> wrote:
> The clj-record README shows how to create an interface to a table > (let's say "employees") with: > > (ns our-warehouse.employee > (:require clj-record.boot)) > > (def db ...a clojure.contrib.sql db-spec...) > > (clj-record.core/init-model) > > As you see, the connection to the database is made within a namespace > that is specific to one particular table. Is there an idiomatic way > to: > - create the connection first (namespace would be for *database* > rather than *table*, so "our-warehouse* in the example above instead > of "our-warehouse.employee") > - create and initialize all the clj-record functions within that > namespace? This is less a question of "idiomatic" than "interface to clj-record". clj-record to have a namespace per thing you define. If this is not what need, you may want to look at carte[1]. It also works with mysql and has a different interface, where what you need, should be easily possible. Sincerely Meikel [1]: http://github.com/brentonashworth/carte PS: > As there are a lot of tables (but the code for connecting to each very > short): is it possible to do all those definitions in the same file? It is, but you will run into trouble when you want to use require. (ns database.table1) (init-model ...) (ns database.table2) (init-model ...) All in one file. But as I said: you will run into trouble with require. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en