Index

RBSQLiteConnection.h

Classes


RBSQLiteConnection

Properties

public dataFilePath NSString { get }

public state RBSQLiteConnectionState { get }

public lastInsertedRowId long long int { get }

public lastErrorMessage NSString? { get }

Functions

Opens the connection to the specified database file.
@param target : The filesystem path to the database file on disk. Create an in memory database by passing in :memory:.
@returns true if the connection was opened successfully, false if there was an error.
- (BOOL)connectToFile:(nonnull NSString *)target;

Opens the connection to the specified database file using a virtual filesystem.
@param target : The filesystem path to the database file on disk.
@param flags : One or more sqlite3 connection flags to use when opening the connection.
@param vfs : The name of the registered virtual filesystem to use.
@returns true if the connection was opened successfully, false if there was an error.
- (BOOL)connectToFile:(nonnull NSString *)target withFlags:(int)flags usingVFS:(nonnull NSString *)vfs;

Executes an SQL query and returns the result set.
@param queryString : The SQL query string to execute, where the '?' character denotes a binding.
@param bindings : The objects to bind respectively to the query string.
@returns An RBSQLiteResult object that provides the resulting data for the executed SQL query, or nil if there was an error.
- (nonnull RBSQLiteResult *)execute:(nonnull NSString *)queryString bindings:(nullable NSArray *)bindings;

Determines whether a table with the given name exists in the database.
@param name : The name of the table.
@returns true if the table exists, false if not.
- (BOOL)tableExistsWithName:(nonnull NSString *)name;

Inspects the table with the given name and creates an RBSQLiteTableSchema object describing it.
@param tableName : The name of the table.
@returns The RBSQLiteTableSchema object, or nil if there was an error.
- (nullable RBSQLiteTableSchema *)schemaFromTableName:(nonnull NSString *)tableName;

Creates a new table, or adjusts an existing table with the same name, using the given RBSQLiteTableSchema. Note: This method only adds missing fields, it does not adjust existing fields.
@param schema : The schema that describes the table to create or amend to.
@returns true if the table was created or amended successfully and now matches the schema, false if there was an error.
- (BOOL)createOrUpdateTableWithSchema:(nonnull RBSQLiteTableSchema *)schema;

Creates a new table using the given RBSQLiteTableSchema.
@param schema : The schema that describes the table to create.
@returns An RBSQLiteResult object that provides the information about the executed SQL query.
- (nonnull RBSQLiteResult *)createTableWithSchema:(nonnull RBSQLiteTableSchema *)schema;

Adjusts an existing table with the same name to match the given RBSQLiteTableSchema. Note: This method only adds missing fields, it does not adjust existing fields.
@param schema : The schema that describes the table to adjust to.
@returns true if the table was updated successfully, false if there was an error.
- (BOOL)updateTableWithSchema:(nonnull RBSQLiteTableSchema *)schema;

Adds a new field to a database table.
@param field : The schema of the field to add.
@param tableName : The name of the table to add the new field to.
@returns An RBSQLiteResult object that provides the information about the executed SQL query.
- (nonnull RBSQLiteResult *)addField:(nonnull RBSQLiteFieldSchema *)field toTable:(nonnull NSString *)tableName;

Copies all tables and data from this database connection to the given database connection.
@param databaseConnection : The database connection to backup to.
@returns true if the backup was successful, false if there was an error.
- (BOOL)backupDatabaseToDatabase:(nonnull RBSQLiteConnection *)databaseConnection;

Copies all tables and data from this database connection to a file.
@param filename : The local filesystem path to create the backup SQLite database file at.
@param flags : One or more sqlite3 connection flags to use when opening the connection to the backup file.
@param vfs : The name of the registered virtual filesystem to use when opening the connection to the backup file.
@returns true if the backup was successful, false if there was an error.
- (BOOL)backupDatabaseToFile:(nonnull NSString *)filename withFlags:(int)flags usingVFS:(nonnull NSString *)vfs;

Reads all of the tables and data from the specified SQLite file into this connection.
@param filename : The path to the database file to read from.
@param flags : One or more sqlite3 connection flags to use when opening the connection.
@param vfs : The name of the registered virtual filesystem to use when opening the connection.
@returns true if the transfer was successful, false if there was an error.
- (BOOL)populateDatabaseFromFile:(nonnull NSString *)filename withFlags:(int)flags usingVFS:(nonnull NSString *)vfs;