Dear Clojure group,
I am currently reading chapter 9.1 MySQL & clj-record of 'Clojure in
Action'.
clj-record seems pretty awesome, but I once again got lost in
namespace jungle.
Here is a concrete example:
--------------------------------------------------------------------------------
File 1: src/active-record/credentials.clj
[Database credentials]
(ns active-record.credentials)
(def db
{:classname "com.mysql.jdbc.Driver"
:subprotocol "mysql"
:user "xxxx"
:password "xxxx"
:subname "//localhost:3306/damages_dev"
})
--------------------------------------------------------------------------------
File 2: src/active-record/user.clj
[Belongs to the database name with the name 'users']
(ns active-record.user
(:use [active-record.credentials :only [db]])
(:require clj-record.boot))
(clj-record.core/init-model
(:associations
(has-many charges)))
--------------------------------------------------------------------------------
File 3: src/active-record/charge.clj
[Belongs to the database name with the name 'charges']
(ns active-record.user
(:use [active-record.credentials :only [db]])
(:require clj-record.boot))
(clj-record.core/init-model
(:associations
(has-many charges)))
--------------------------------------------------------------------------------
I want to add/remove/alter table entries in a different file:
File 4: src/active-record/program/core.clj
All my efforts to import the user.clj and charge.clj namespaces have
failed so far. For example, I have tried the following namespace
declaration:
(ns active-record.program.core
(:require [active-record.user :as user])
(:require [active-record.charge :as charge])
(:require clj-record.boot))
(user/create
{:login "rob"
:first_name "Robert"
:last_name "Berger"
:password "secret"
:email_address "
r...@runa.com"})
;; No such var: user/create
;; [Thrown class java.lang.Exception]
This one doesn't work either:
(ns active-record.program.core
(:require [active-record.user :as user])
(:require [active-record.charge :as charge]))
;; EOF while reading
;; [Thrown class java.lang.Exception]
Can anybody tell me what went wrong in the example above?
Stefan