On Nov 8, 12:47 pm, loonster <tbur...@acm.org> wrote:
> After searching long and hard, there really isn't any good
> documentation for using sqlite3 with clojure 1.3.  Any help connecting
> to an existing sqlite3 db and performing selects and updates greatly
> appreciated.   Tim

Thanks all.  In the end, the following works like a charm.  I found
that clojure/java/jdbc namespace has a conflict with clojure/core,
both having resultset-seq function, hence the exclusion:

(ns psyN.core
 (:use [clojure.java.jdbc])
 (defproject psyN "0.1.0"
  :dependencies [[org.clojure/clojure "1.3.0"]
                [org.clojure/java.jdbc "0.1.1"]
                [org.xerial/sqlite-jdbc "3.7.2"]])
;**********************************************************
(ns psyN.core
  (:use [clojure.java.jdbc])
  (:refer-clojure :exclude [resultset-seq]))


(def db
  {:classname   "org.sqlite.JDBC"
   :subprotocol "sqlite"
   :subname     "/path/to the sqlite file/psyN/db/thx"
  })

;get count of table.notes records:
(def rec-cnt
  (with-connection db
    (with-query-results rs ["select * from notes"]
      (count rs))))

(def output
  (with-connection db
   (with-query-results rs ["SELECT * FROM notes WHERE id = ?" (+ 1
(rand-int rec-cnt))]
      (into {} rs))))

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to