Database.execute

Executes a single SQL statement and returns the results directly.

It's the equivalent of prepare(sql).execute(). Or when used with args the equivalent of:

auto stm = prepare(sql);
stm.bindAll(args);
stm.execute();

The results become undefined when the Database goes out of scope and is destroyed.

struct Database
private public
execute
(
Args...
)
(
string sql
,
Args args
)

Parameters

sql string

The code of the SQL statement.

args Args

Optional arguments to bind to the SQL statement.

Examples

auto db = Database(":memory:");
db.execute("CREATE TABLE test (val INTEGER)");
db.execute("INSERT INTO test (val) VALUES (:v)", 1);
assert(db.execute("SELECT val FROM test WHERE val=:v", 1).oneValue!int == 1);

Meta