简体   繁体   English

我如何使用clojure jdbc执行?

[英]How do I use clojure jdbc execute?

I'm struggling to get the jdbc/execute! 我正在努力获得jdbc/execute! function to commit any changes I make to my sqlite database. 函数提交我对sqlite数据库所做的任何更改。

For example, 例如,

user=> (jdbc/execute! sqlite-db ["insert into person (second_name) values ('Gandhi');"])
nil

nil is returned and the row is not inserted. 返回nil并且未插入行。 However, I know the function is connecting to the database somehow because I can use an invalid table name and get an error: 但是,我知道该函数以某种方式连接到数据库,因为我可以使用无效的表名并得到错误:

user=> (jdbc/execute! sqlite-db ["insert into ABCDEFG (second_name) values ('Gandhi');"])

SQLException [SQLITE_ERROR] SQL error or missing database (no such table: ABCDEFG)  org.sqlite.DB.newSQLException (DB.java:383)

The jdbc library also includes a jdbc/insert! jdbc库还包含一个jdbc/insert! function, and I can insert correctly using this. 功能,我可以使用这个正确插入。 However, I wanted to use the execute! 但是,我想使用execute! function instead because in my application I use a more complex statement and I thought I would therefore supply a parameterized sql string. 函数而不是因为在我的应用程序中我使用了一个更复杂的语句,我想我会提供一个参数化的sql字符串。

Where am I going wrong using the execute! 我在哪里使用execute!错误execute! function? 功能?

At the time of this answer -> Using execute! 在这个答案的时候 - > 使用执行! with no params to insert a row fails on SQLite <- is listed as still an open issue to be resolved in beta 0.3.0 of java.jdbc 没有参数在SQLite上插入行失败 < - 被列为仍然是在java.jdbc的beta 0.3.0中解决的开放问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM