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
execute
(
Args...
)
(
string sql
,
Args args
)

Parameters

sql
Type: string

The code of the SQL statement.

args
Type: 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