This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-05-18
Channels
- # announcements (9)
- # atom-editor (29)
- # aws (17)
- # babashka (72)
- # beginners (83)
- # braveandtrue (3)
- # calva (7)
- # cider (16)
- # clj-kondo (15)
- # cljs-dev (146)
- # cljsjs (1)
- # cljsrn (8)
- # clojars (1)
- # clojure (96)
- # clojure-dev (19)
- # clojure-europe (53)
- # clojure-losangeles (1)
- # clojure-nl (3)
- # clojure-spec (7)
- # clojure-uk (235)
- # clojuredesign-podcast (5)
- # clojurescript (81)
- # conjure (73)
- # cursive (7)
- # data-science (1)
- # datomic (5)
- # defnpodcast (8)
- # emacs (3)
- # figwheel-main (34)
- # fulcro (83)
- # graalvm (10)
- # graphql (6)
- # helix (49)
- # jackdaw (3)
- # jobs (1)
- # joker (1)
- # kaocha (1)
- # mid-cities-meetup (10)
- # off-topic (17)
- # pathom (16)
- # re-frame (11)
- # reagent (18)
- # reitit (18)
- # remote-jobs (4)
- # shadow-cljs (63)
- # spacemacs (18)
- # specter (20)
- # sql (17)
- # uncomplicate (1)
- # vim (28)
- # xtdb (32)
what's the proper syntax for next.jdbc :dbname db spec for indicating a sqlite local file that lives in resources/dbfile.db? :dbname "resources/dbfile.db"
doesn't seem to work
@watchtheblur Can you expand on "doesn't seem to work"? When I tried that, it works.
user=> (def ds (jdbc/get-datasource {:dbtype "sqlite" :dbname "resources/dbfile.db"}))
#'user/ds
user=> (jdbc/execute! ds ["select 1 as foo"])
[{:foo 1}]
user=>
This creates resources/dbfile.db
as expected for me.I get the following error when I use code similar to yours (with the filename different):
(jdbc/execute! ds ["select 1 as foo"])
Execution error (SQLException) at java.sql.DriverManager/getConnection (DriverManager.java:689).
No suitable driver found for jdbc:sqlite:resources/rmfetch.db
Here's my code:
(def db {:dbtype "sqlite" :dbname "resources/rmfetch.db"})
(def ds (jdbc/get-datasource db))
(jdbc/execute! ds ["select 1 as foo"])
I don't see it explicitly called out in the docs https://cljdoc.org/d/seancorfield/next.jdbc/1.0.424/doc/getting-started but in addition to next.jdbc you need the actual driver that will be used to connect to the db
It was the driver line that was missing. Thanks again @dpsutton and @U04V70XH6. I went back and read the link above and the last paragraph under "Installation" shows how to put in the driver line.
@dpsutton The last paragraph of the Installation section says: > In addition, you will need to add dependencies for the JDBC drivers you wish to use for whatever databases you are using. You can see the drivers and versions that next.jdbc is tested against in the project's deps.edn file, but many other JDBC drivers for other databases should also work (e.g., Oracle, Red Shift).
Ah, I see you found that in the docs.
Gotcha!
> In addition, you will need to add dependencies for the JDBC drivers you wish to use for whatever databases you are using. You can see the drivers and versions that `next.jdbc` is tested against in https://github.com/seancorfield/next-jdbc/blob/master/deps.edn#L11-L24`deps.edn`https://github.com/seancorfield/next-jdbc/blob/master/deps.edn#L11-L24, but many other JDBC drivers for other databases should also work (e.g., Oracle, Red Shift).