Function Database.execute

Executes a single SQL statement and returns the results directly.

ResultRange execute(Args...) (
  string sql,
  Args args
);

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.

Parameters

NameDescription
sql The code of the SQL statement.
args Optional arguments to bind to the SQL statement.

Example

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);