user6324692
user6324692

Reputation:

How to setup Korma in Luminus or Compojure projects?

I'm trying to use Korma and set it up for my Luminus project. Korma has the following helpers for Postgresql:

;; how exactly should I pass the connection string here?
;; in particular, for production env.

(def pg (postgres ..))

(defdb korma-db db)

(defdb prod (postgres {:db "korma"
                       :user "korma"
                       ;;.....

How can I and should I at all somehow utilize the file profiles.clj where I have the test and dev connection strings for PG for setting up Korma?

If so, in profiles.clj there's no "production" connection string, should I add it or what?

Upvotes: 0

Views: 178

Answers (3)

Brian
Brian

Reputation: 967

You could add a "production" variable, but you have other options. Current versions of luminus use cprop for environment variables. Using it, you have the option of putting these variables in config.edn, or a completely separate file:

(load-config :file "/path/to/another.edn")

There are also separate files for each environment you could use, e.g., env/prod/clj//env.clj.

Upvotes: 0

Taha Husain
Taha Husain

Reputation: 312

Take a look at nomad. It takes out all env specific and common strings/constants in a separate file. Having one file always makes project constants more manageable.

Upvotes: 0

Édipo Féderle
Édipo Féderle

Reputation: 4257

I don't know if I understand correctly your question, but maybe you should take a look at this: https://github.com/weavejester/environ. A clojure library for managing environment variables.

In your profiles.clj you will set something like:

{:dev  {:env {:database-url "jdbc:postgres://localhost/dev"}}
 :test {:env {:database-url "jdbc:postgres://localhost/test"}}}

Upvotes: 0

Related Questions