gosqlite3 icon indicating copy to clipboard operation
gosqlite3 copied to clipboard

Please consider adding support for sqlite3_exec()

Open kostix opened this issue 12 years ago • 1 comments

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?

  1. http://www.sqlite.org/c3ref/exec.html

kostix avatar Oct 03 '12 21:10 kostix

It should be a fairly simple addition, and when I get a spare half-hour I'll investigate further.

feyeleanor avatar Oct 04 '12 21:10 feyeleanor