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
note in hte example there he is using com.h2database/h2
.
> 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).
I am indeed missing that in my deps.edn. Thanks @dpsutton I'll try that now
It was the driver line that was missing. Thanks again @dpsutton and @seancorfield. 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.
yeah i was trying to mark out my responses. and i quoted that after i saw it 🙂
i couldnt' figure out the right sequence of tilde's to mark through my text 🙂
Gotcha!
I saw him do it live so I can testify to its veracity 😉
haha thanks