Question

I am trying to use clojure kORMa with compojure, the webapp is here nepleaks.

First I added kORMa dependency

[korma "0.3.0-RC4"]

lein deps works cool, then created src/hotel/conf/datasource.clj which looks as follows :

(ns hotel.conf.datasource)
   (use [korma.db])
   (use [korma.core])
)

(defdb db (mysql {:db "nepleaks"
                     :user "root"
                     :password "mysql55"}))

(defentity users)

lein ring server is neither throwing any exception nor creating the database entity.

Am I missing something? Do I need more configuration?

Was it helpful?

Solution

My understanding is that Korma does not create the database nor the database tables for you, so you need to create them beforehand manually.

OTHER TIPS

In the spirit of an example being worth 1000 words, I would recommend checking out the luminus clojure web framework. See http://www.luminusweb.net/ This framework sets up a lot of really useful libraries with very basic example use, including korma, ragtime, ring, compojure and some other nice libs. The default templates show you lots of nice ways of using these libraries and how to integrate them. You can then pick the bits you want. All you need to do to get started is run

lein new luminus <your project> +mysql

The web site has good documentation and the code is pretty clean and easy to understand. Saves hours when wanting to get up and running with a new library you are still comming to terms with.

you need lein ragtime plugin manage the database.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top