This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-09-29
Channels
- # announcements (4)
- # babashka (66)
- # beginners (7)
- # cljs-dev (6)
- # clojure (12)
- # clojure-europe (28)
- # clojure-nl (1)
- # clojure-norway (75)
- # clojure-uk (16)
- # clojuredesign-podcast (1)
- # clojurescript (16)
- # datascript (6)
- # deps-new (2)
- # dev-tooling (40)
- # exercism (1)
- # fulcro (92)
- # hyperfiddle (25)
- # lsp (19)
- # malli (1)
- # meander (2)
- # nrepl (9)
- # off-topic (5)
- # pathom (1)
- # practicalli (1)
- # re-frame (20)
- # reitit (14)
- # releases (1)
- # sci (86)
- # shadow-cljs (216)
- # sql (13)
- # testing (4)
- # tools-deps (4)
- # vscode (3)
Hi everyone, I am having an issue with next.jdbc
and sqlite
where I try to run the following:
(jdbc/execute! ds ["INSERT INTO card_model(uuid, name, image) VALUES('1', '2', '3') ON CONFLICT(uuid) DO UPDATE SET name = EXCLUDED.name"])
, but I get the following error: [SQLITE_ERROR] SQL error or missing database (near "ON": syntax error)
.
I can run other SQL statements just fine, so assume the connection to the database is working just fine. so it's seems to me it's a SQL syntax issue, but I can run the exact same statement using sqite3 cli and it runs just fine, but somehow when I run trough jdbc I get this error. Anyone have any ideas on what I am doing wrong? Thanks in advance!
No, I am using a local file
or at least I think I am, this is my datasource obj:
(jdbc/get-datasource {:dbtype "sqlite"
:dbname "resources/db/main.db"})
Try to use a persistent connection:
(def conn (jdbc/get-connection ...))
and then pass the connection object to all the query/execute functionsI still have the same issue as before:
(def conn (jdbc/get-connection {:dbtype "sqlite"
:dbname "resources/db/main.db"}))
(jdbc/execute! conn ["INSERT INTO card_model(uuid, name, image) VALUES(\" 1\", '2', '3') ON CONFLICT(uuid) DO UPDATE SET name = EXCLUDED.name"])
Interesting is that if I remove the part from ON CONFLICT....
it seems to work finebut I don't see anything wrong with the syntax
Is your jdbc sqlite version up to date? https://www.sqlite.org/lang_conflict.html indicates support for insert...on conflict
was added in 3.24.0
, and the current lib version is at 3.43.0.0
: https://mvnrepository.com/artifact/org.xerial/sqlite-jdbc
More version history: https://www.sqlite.org/lang_upsert.html#history
Yeah that was exactly the issue, I upgraded to version 3.43.0.0
and now it works, nice! thank you!
I think I just used the version that was on Getting Started page from next.jdbc, even though it's written there to search for the latest version 😅
I'll update Getting Started to use newer versions https://github.com/seancorfield/next-jdbc/issues/258
nice thanks! 😀
It's updated in git. Might be a while before I release a new version for it to get to http://cljdoc.org.