gosqlite3
gosqlite3 copied to clipboard
Please consider adding support for sqlite3_exec()
I've just tried to do something like this (which seemed sensible at the moment):
db, err := sqlite.Open("/tmp/foo.db", ...) ... _, err = db.Execute(stmt) ...
const stmt = ` CREATE TABLE settings (name text, value text);
CREATE TABLE bar (foo text, blah text);
INSERT INTO bar
(foo, blah)
VALUES
('xxx', 'yyy'),
('zzz', 'blorb')
... `
and got only the first statement executed, successfully.
I suppose this is as expected, as I have probably had to split my batch into single statements and run db.Execute() on each of them. The "problem" is that this batch is intended to initialize and prepopulate the database, so having one single batch of statements is just logical and convenient.
If my understanding of the API documentation [1] is correct, a wrapper around sqlite3_exec() would do exactly what I need. Is it possible to implement it?
- http://www.sqlite.org/c3ref/exec.html
It should be a fairly simple addition, and when I get a spare half-hour I'll investigate further.