clojureleiningenringlighttablekorma

No valid DB connection selected


I'm developing a web project using Clojure, and I ran into the following problem.

I've defined a db connection with korma using the following code in (ns foo.models.db)

(defdb db
    (mysql {:host "localhost"
            :port "3306"
            :db "foo"
            :delimiters "`"
            :user user
            :password password}
           )

and in LightTable I can initialize the server in an Instarepl using (use 'foo.repl) (start-server), and everything works fine with the database.

However, when I tried running the project in the console using lein ring server, it throws an exception telling me

No valid DB connection selected

Any idea about how I can fix this problem? Thanks.


Solution

  • Found the solution, silly me.

    I've added some draft forms for convenience to evaluate in LightTable to see if the behavior is expected, and these forms do some changes in the database.

    Before the application is bootstrapped, these forms are evaluated, and then produce the errors of "no valid DB connection selected".

    Just remove these forms it went back on track.