Database

An database connection.

This struct is a reference-counted wrapper around a sqlite3* pointer.

Constructors

this
this(string path, int flags)

Opens a database connection.

Members

Functions

attachedFilePath
string attachedFilePath(string database)

Gets the path associated with an attached database.

begin
void begin()

Convenience functions equivalent to an SQL statement.

changes
int changes()

Gets the number of database rows that were changed, inserted or deleted by the most recently executed SQL statement.

close
void close()

Explicitly closes the database connection.

commit
void commit()

Convenience functions equivalent to an SQL statement.

config
void config(int code, Args args)

Sets a connection configuration option.

createAggregate
void createAggregate(string name, T agg, Deterministic det)

Creates and registers a new aggregate function in the database.

createCollation
void createCollation(string name, T fun)

Creates and registers a collation function in the database.

createFunction
void createFunction(string name, T fun, Deterministic det)
void createFunction(string name, T fun)

Creates and registers a new function in the database.

enableLoadExtensions
void enableLoadExtensions(bool enable)

Enables or disables loading extensions.

errorCode
int errorCode()

Gets the SQLite error code of the last operation.

execute
ResultRange execute(string sql, Args args)

Executes a single SQL statement and returns the results directly.

handle
sqlite3* handle()

Gets the SQLite internal handle of the database connection.

interrupt
void interrupt()

Interrupts any pending database operations.

isReadOnly
bool isReadOnly(string database)

Gets the read-only status of an attached database.

lastInsertRowid
long lastInsertRowid()

Returns the rowid of the last INSERT statement.

loadExtension
void loadExtension(string path, string entryPoint)

Loads an extension.

prepare
Statement prepare(string sql)

Prepares (compiles) a single SQL statement and returns it, so that it can be bound to values before execution.

rollback
void rollback()

Convenience functions equivalent to an SQL statement.

run
void run(string script, bool delegate(ResultRange) dg)

Runs an SQL script that can contain multiple statements.

setCommitHook
void setCommitHook(CommitHookDelegate commitHook)

Registers a delegate of type CommitHookDelegate as the database's commit hook. Any previously set hook is released.

setProfileCallback
void setProfileCallback(ProfileCallbackDelegate profileCallback)

Registers a delegate of type ProfileCallbackDelegate as the profile callback.

setProgressHandler
void setProgressHandler(int pace, ProgressHandlerDelegate progressHandler)

Registers a delegate of type ProgressHandlerDelegate as the progress handler.

setRollbackHook
void setRollbackHook(RoolbackHookDelegate rollbackHook)

Registers a delegate of type RoolbackHookDelegate as the database's rollback hook.

setTraceCallback
void setTraceCallback(TraceCallbackDelegate traceCallback)

Registers a delegate of type TraceCallbackDelegate as the trace callback.

setUnlockNotifyHandler
void setUnlockNotifyHandler(IUnlockNotifyHandler unlockNotifyHandler)

Registers a IUnlockNotifyHandler used to handle database locks.

setUpdateHook
void setUpdateHook(UpdateHookDelegate updateHook)

Registers a delegate of type UpdateHookDelegate as the database's update hook.

tableColumnMetadata
TableColumnMetadata tableColumnMetadata(string table, string column, string database)

Gets metadata for a specific table column of an attached database.

totalChanges
int totalChanges()

Gets the number of database rows that were changed, inserted or deleted since the database was opened.

waitForUnlockNotify
auto waitForUnlockNotify()

Setup and waits for unlock notify using the provided IUnlockNotifyHandler

Meta