Statement
A statement represents an SQL query.
-
The raw SQLite statement, suitable for the SQLite C API.
-
The SQL query
-
The column names, ordered from left to right.
-
The database region that the statement looks into.
-
Returns true if and only if the prepared statement makes no direct changes to the content of the database file.
-
The statement arguments.
-
Throws a DatabaseError of code SQLITE_ERROR if arguments don’t fill all statement arguments.
For example:
let statement = try db.makeUpdateArgument(sql: """ INSERT INTO player (id, name) VALUES (?, ?) """) // OK statement.validateArguments([1, "Arthur"]) // Throws statement.validateArguments([1])
See also setArguments(_:)
-
Set arguments without any validation. Trades safety for performance.
Only call this method if you are sure input arguments match all expected arguments of the statement.
For example:
let statement = try db.makeUpdateArgument(sql: """ INSERT INTO player (id, name) VALUES (?, ?) """) // OK statement.setUncheckedArguments([1, "Arthur"]) // OK let arguments: StatementArguments = ... // some untrusted arguments try statement.validateArguments(arguments) statement.setUncheckedArguments(arguments) // NOT OK statement.setUncheckedArguments([1])
-
Set the statement arguments, or throws a DatabaseError of code SQLITE_ERROR if arguments don’t fill all statement arguments.
For example:
let statement = try db.makeUpdateArgument(sql: """ INSERT INTO player (id, name) VALUES (?, ?) """) // OK try statement.setArguments([1, "Arthur"]) // Throws an error try statement.setArguments([1])
-
Executes the prepared statement.
Throws
A DatabaseError whenever an SQLite error occurs. -
-
The number of columns in the resulting rows.
-
Returns the index of the leftmost column named
name
, in a case-insensitive way.