http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go
However, if you have the JAR on your classpath, that namespace should
be available.
It would help people help you if you provided more detail:
* How are you running your Clojure code?
* What _exact_ error message (and partial stack trace) are you seeing?
Here's an example workflow that shows you can access
clojure.contrib.sql just fine:
sean@sean-netbook:~/clojure$ lein new jay
cd Created new project in: /home/sean/clojure/jay
Look over project.clj and start coding in jay/core.clj
sean@sean-netbook:~/clojure$ cd jay/
sean@sean-netbook:~/clojure/jay$ vi project.clj
sean@sean-netbook:~/clojure/jay$ cat project.clj
(defproject jay "1.0.0-SNAPSHOT"
:description "FIXME: write description"
:dependencies [[org.clojure/clojure "1.2.1"]
[org.clojure/clojure-contrib "1.2.0"]])
sean@sean-netbook:~/clojure/jay$ lein deps
Copying 2 files to /home/sean/clojure/jay/lib
sean@sean-netbook:~/clojure/jay$ lein repl
REPL started; server listening on localhost port 13024
user=> (ns jay.test (:require [clojure.contrib.sql :as sql]))
nil
jay.test=> ^D
Sean
(defn drop-users []
(sql/drop-table :users))
(sql/with-connection db
(create-users))
(defn insert-user [fname lname]
(sql/insert-values :users [:fname :lname] [fname lname]))
(sql/with-connection db
(insert-user "Sandy" "Brown"))
(sql/with-connection db
(sql/with-query-results rs ["select * from users"]
(dorun (map #(println %) rs))))
===================================
Do I include this statement to get sql and what is the proper way??
(:require [clojure.contrib.sql :as sql]))
http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go
Sean
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@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+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
Looks like you're missing a line here before :subprotocol...?
> :subprotocol "mysql"
> :subname "//localhost:3306/dummy"
> :user "root"
> :password "pass"})
> (defn create-users []
> (sql/create-table
> :users
> [:id :integer "PRIMARY KEY" "AUTO_INCREMENT"]
> [:fname "varchar(25)"]
> [:lname "varchar(25)"]))
>
> (defn drop-users []
> (sql/drop-table :users))
> (sql/with-connection db
> (create-users))
> (defn insert-user [fname lname]
> (sql/insert-values :users [:fname :lname] [fname lname]))
>
> (sql/with-connection db
> (insert-user "Sandy" "Brown"))
> (sql/with-connection db
> (sql/with-query-results rs ["select * from users"]
> (dorun (map #(println %) rs))))
>
> ===================================
> Do I include this statement to get sql and what is the proper way??
>
> (:require [clojure.contrib.sql :as sql]))
You haven't answered the questions about how you are running your
Clojure code (what's on your classpath etc).
Did you try the process I outlined?
> ----- Original Message ----- From: "Sean Corfield" <seanco...@gmail.com>
C:\>path
PATH=C:\Perl\site\bin;C:\Perl\bin;C:\Windows\system32;C:\Windows;C:\Windows\Syst
em32\Wbem;C:\hp\bin\Python;c:\Program Files\Common Files\Roxio
Shared\DLLShared\
;c:\Program Files\Common Files\Roxio Shared\9.0\DLLShared\;C:\Program
Files\jZip
;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program
Files\QuickTime\QTSystem
\;c:\lein;c:\cljr\.cljr\bin;c:\opt\;c:\program files\mysql\mysql server
5.5\bin
C:\>set classpath
CLASSPATH=c:/opt/jars/*;c:/projects/clarity4/src
C:\>
--
No one is going to be able to help you if you don't provide enough
details about what _exactly_ you are doing and what error / stack
trace you are getting.
Please also try the command sequence I showed you and see if that works.
It's just declaring a namespace and requiring clojure.contrib.sql
(which loads the library). I called it jay.test because it was a test
for Jay :)
> The other code I listed was code to run as a clojure program , not as
> leiningen, which you said was missing lines of code after the (ns
You have not shown how you actually RUN the code. Since you're not
using Leiningen, I suspect you have a classpath problem but you need
to show us exactly how you are trying to run the code for us to help
debug that.
> I apologize for my lack of understanding, but I feel I must be able to
> access databases or I can't use clojure
I'm sure it's just something simple missing in how you are trying to
run the code. As I've shown, the code itself is likely fine since my
example loads clojure.contrib.sql correctly (because I'm using
Leiningen, the classpath issues are taken care of).
--
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/
"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)