GPKGSqlUtils

Objective-C

@interface GPKGSqlUtils : NSObject

Swift

class GPKGSqlUtils : NSObject

SQL utility methods

  • Execute statement on the database

    Declaration

    Objective-C

    + (void)execWithDatabase:(GPKGDbConnection *)connection
                andStatement:(NSString *)statement;

    Swift

    class func exec(withDatabase connection: GPKGDbConnection!, andStatement statement: String!)

    Parameters

    connection

    connection

    statement

    statement

  • Execute statement on the SQLite connection

    Declaration

    Objective-C

    + (void)execWithSQLiteConnection:(GPKGSqliteConnection *)connection
                        andStatement:(NSString *)statement;

    Swift

    class func exec(withSQLiteConnection connection: GPKGSqliteConnection!, andStatement statement: String!)

    Parameters

    connection

    connection

    statement

    statement

  • Query statement on the database

    Declaration

    Objective-C

    + (GPKGResultSet *)queryWithDatabase:(GPKGDbConnection *)connection
                            andStatement:(NSString *)statement
                                 andArgs:(NSArray *)args;

    Swift

    class func query(withDatabase connection: GPKGDbConnection!, andStatement statement: String!, andArgs args: [Any]!) -> GPKGResultSet!

    Parameters

    connection

    connection

    statement

    statement

    args

    statement args

    Return Value

    result set

  • Query on the database

    Declaration

    Objective-C

    + (GPKGResultSet *)queryWithDatabase:(GPKGDbConnection *)connection
                             andDistinct:(BOOL)distinct
                                andTable:(NSString *)table
                              andColumns:(NSArray<NSString *> *)columns
                                andWhere:(NSString *)where
                            andWhereArgs:(NSArray *)whereArgs
                              andGroupBy:(NSString *)groupBy
                               andHaving:(NSString *)having
                              andOrderBy:(NSString *)orderBy
                                andLimit:(NSString *)limit;

    Swift

    class func query(withDatabase connection: GPKGDbConnection!, andDistinct distinct: Bool, andTable table: String!, andColumns columns: [String]!, andWhere where: String!, andWhereArgs whereArgs: [Any]!, andGroupBy groupBy: String!, andHaving having: String!, andOrderBy orderBy: String!, andLimit limit: String!) -> GPKGResultSet!

    Parameters

    connection

    connection

    distinct

    distinct flag

    table

    table

    columns

    columns

    where

    where clause

    whereArgs

    where args

    groupBy

    group by clause

    having

    having clause

    orderBy

    order by clause

    limit

    limit clause

    Return Value

    result set

  • Build Query SQL

    Declaration

    Objective-C

    + (NSString *)querySQLWithDistinct:(BOOL)distinct
                              andTable:(NSString *)table
                            andColumns:(NSArray<NSString *> *)columns
                              andWhere:(NSString *)where
                            andGroupBy:(NSString *)groupBy
                             andHaving:(NSString *)having
                            andOrderBy:(NSString *)orderBy
                              andLimit:(NSString *)limit;

    Swift

    class func querySQL(withDistinct distinct: Bool, andTable table: String!, andColumns columns: [String]!, andWhere where: String!, andGroupBy groupBy: String!, andHaving having: String!, andOrderBy orderBy: String!, andLimit limit: String!) -> String!

    Parameters

    distinct

    distinct flag

    table

    table

    columns

    columns

    where

    where clause

    groupBy

    group by clause

    having

    having clause

    orderBy

    order by clause

    limit

    limit clause

    Return Value

    result set

  • Count on the database

    Declaration

    Objective-C

    + (int)countWithDatabase:(GPKGDbConnection *)connection
                andStatement:(NSString *)statement
                     andArgs:(NSArray *)args;

    Swift

    class func count(withDatabase connection: GPKGDbConnection!, andStatement statement: String!, andArgs args: [Any]!) -> Int32

    Parameters

    connection

    connection

    statement

    count statement

    args

    statement args

    Return Value

    count

  • Count on the database table where

    Declaration

    Objective-C

    + (int)countWithDatabase:(GPKGDbConnection *)connection
                    andTable:(NSString *)table;

    Swift

    class func count(withDatabase connection: GPKGDbConnection!, andTable table: String!) -> Int32

    Parameters

    connection

    connection

    table

    table

    Return Value

    count

  • Count on the database table where

    Declaration

    Objective-C

    + (int)countWithDatabase:(GPKGDbConnection *)connection
                    andTable:(NSString *)table
                    andWhere:(NSString *)where;

    Swift

    class func count(withDatabase connection: GPKGDbConnection!, andTable table: String!, andWhere where: String!) -> Int32

    Parameters

    connection

    connection

    table

    table

    where

    where clause

    Return Value

    count

  • Count on the database table where

    Declaration

    Objective-C

    + (int)countWithDatabase:(GPKGDbConnection *)connection
                    andTable:(NSString *)table
                    andWhere:(NSString *)where
                andWhereArgs:(NSArray *)whereArgs;

    Swift

    class func count(withDatabase connection: GPKGDbConnection!, andTable table: String!, andWhere where: String!, andWhereArgs whereArgs: [Any]!) -> Int32

    Parameters

    connection

    connection

    table

    table

    where

    where clause

    whereArgs

    where args

    Return Value

    count

  • Count on the database

    Declaration

    Objective-C

    + (int)countWithDatabase:(GPKGDbConnection *)connection
           andCountStatement:(NSString *)countStatement;

    Swift

    class func count(withDatabase connection: GPKGDbConnection!, andCountStatement countStatement: String!) -> Int32

    Parameters

    connection

    database connection

    countStatement

    count statement

    Return Value

    count

  • Count on the database

    Declaration

    Objective-C

    + (int)countWithDatabase:(GPKGDbConnection *)connection
           andCountStatement:(NSString *)countStatement
                     andArgs:(NSArray *)args;

    Swift

    class func count(withDatabase connection: GPKGDbConnection!, andCountStatement countStatement: String!, andArgs args: [Any]!) -> Int32

    Parameters

    connection

    connection

    countStatement

    count statement

    args

    statement args

    Return Value

    count

  • Get a count of table results

    Declaration

    Objective-C

    + (int)countWithDatabase:(GPKGDbConnection *)connection
                    andTable:(NSString *)table
                   andColumn:(NSString *)column;

    Swift

    class func count(withDatabase connection: GPKGDbConnection!, andTable table: String!, andColumn column: String!) -> Int32

    Parameters

    connection

    connection

    table

    table name

    column

    column name

    Return Value

    count

  • Get a count of table results

    Declaration

    Objective-C

    + (int)countWithDatabase:(GPKGDbConnection *)connection
                    andTable:(NSString *)table
                 andDistinct:(BOOL)distinct
                   andColumn:(NSString *)column;

    Swift

    class func count(withDatabase connection: GPKGDbConnection!, andTable table: String!, andDistinct distinct: Bool, andColumn column: String!) -> Int32

    Parameters

    connection

    connection

    table

    table name

    distinct

    distinct column flag

    column

    column name

    Return Value

    count

  • Get a count of table results

    Declaration

    Objective-C

    + (int)countWithDatabase:(GPKGDbConnection *)connection
                    andTable:(NSString *)table
                   andColumn:(NSString *)column
                    andWhere:(NSString *)where
                andWhereArgs:(NSArray *)whereArgs;

    Swift

    class func count(withDatabase connection: GPKGDbConnection!, andTable table: String!, andColumn column: String!, andWhere where: String!, andWhereArgs whereArgs: [Any]!) -> Int32

    Parameters

    connection

    connection

    table

    table name

    column

    column name

    where

    where clause

    whereArgs

    arguments

    Return Value

    count

  • Get a count of table results

    Declaration

    Objective-C

    + (int)countWithDatabase:(GPKGDbConnection *)connection
                    andTable:(NSString *)table
                 andDistinct:(BOOL)distinct
                   andColumn:(NSString *)column
                    andWhere:(NSString *)where
                andWhereArgs:(NSArray *)whereArgs;

    Swift

    class func count(withDatabase connection: GPKGDbConnection!, andTable table: String!, andDistinct distinct: Bool, andColumn column: String!, andWhere where: String!, andWhereArgs whereArgs: [Any]!) -> Int32

    Parameters

    connection

    connection

    table

    table name

    distinct

    distinct column flag

    column

    column name

    where

    where clause

    whereArgs

    arguments

    Return Value

    count

  • Query the SQL for a single result object with the expected data type

    Declaration

    Objective-C

    + (NSObject *)querySingleResultWithDatabase:(GPKGDbConnection *)connection
                                         andSql:(NSString *)sql
                                        andArgs:(NSArray *)args
                                      andColumn:(int)column
                                    andDataType:(enum GPKGDataType)dataType;

    Swift

    class func querySingleResult(withDatabase connection: GPKGDbConnection!, andSql sql: String!, andArgs args: [Any]!, andColumn column: Int32, andDataType dataType: GPKGDataType) -> NSObject!

    Parameters

    connection

    connection

    sql

    sql statement

    args

    arguments

    column

    column index

    dataType

    GeoPackage data type

    Return Value

    result, null if no result

  • Query for values from a single column up to the limit

    Declaration

    Objective-C

    + (NSArray<NSObject *> *)
        querySingleColumnResultsWithDatabase:(GPKGDbConnection *)connection
                                      andSql:(NSString *)sql
                                     andArgs:(NSArray *)args
                                   andColumn:(int)column
                                 andDataType:(enum GPKGDataType)dataType
                                    andLimit:(NSNumber *)limit;

    Swift

    class func querySingleColumnResults(withDatabase connection: GPKGDbConnection!, andSql sql: String!, andArgs args: [Any]!, andColumn column: Int32, andDataType dataType: GPKGDataType, andLimit limit: NSNumber!) -> [NSObject]!

    Parameters

    connection

    connection

    sql

    sql statement

    args

    arguments

    column

    column index

    dataType

    GeoPackage data type

    limit

    result row limit

    Return Value

    single column results

  • Query for values up to the limit

    Declaration

    Objective-C

    + (NSArray<GPKGRow *> *)queryResultsWithDatabase:(GPKGDbConnection *)connection
                                              andSql:(NSString *)sql
                                             andArgs:(NSArray *)args
                                        andDataTypes:(NSArray *)dataTypes
                                            andLimit:(NSNumber *)limit;

    Swift

    class func queryResults(withDatabase connection: GPKGDbConnection!, andSql sql: String!, andArgs args: [Any]!, andDataTypes dataTypes: [Any]!, andLimit limit: NSNumber!) -> [GPKGRow]!

    Parameters

    connection

    connection

    sql

    sql statement

    args

    arguments

    dataTypes

    column data types

    limit

    result row limit

    Return Value

    results

  • Get the value from the result set from the provided column

    Declaration

    Objective-C

    + (NSObject *)valueInResult:(GPKGResultSet *)result atIndex:(int)index;

    Swift

    class func value(inResult result: GPKGResultSet!, at index: Int32) -> NSObject!

    Parameters

    result

    result

    index

    index

    Return Value

    value

  • Get the value from the result set from the provided column

    Declaration

    Objective-C

    + (NSObject *)valueInResult:(GPKGResultSet *)result
                        atIndex:(int)index
                   withDataType:(enum GPKGDataType)dataType;

    Swift

    class func value(inResult result: GPKGResultSet!, at index: Int32, with dataType: GPKGDataType) -> NSObject!

    Parameters

    result

    result

    index

    index

    dataType

    data type

    Return Value

    value

  • Get the value from the result set from the provided column

    Declaration

    Objective-C

    + (NSObject *)valueInResult:(GPKGResultSet *)result
                        atIndex:(int)index
                       withType:(int)type;

    Swift

    class func value(inResult result: GPKGResultSet!, at index: Int32, withType type: Int32) -> NSObject!

    Parameters

    result

    result

    index

    index

    type

    sqlite3 column type: SQLITE_INTEGER, SQLITE_FLOAT, SQLITE_STRING, SQLITE_BLOB, or SQLITE_NULL

    Return Value

    value

  • Get the value from the result set from the provided column

    Declaration

    Objective-C

    + (NSObject *)valueInResult:(GPKGResultSet *)result
                        atIndex:(int)index
                       withType:(int)type
                    andDataType:(enum GPKGDataType)dataType;

    Swift

    class func value(inResult result: GPKGResultSet!, at index: Int32, withType type: Int32, andDataType dataType: GPKGDataType) -> NSObject!

    Parameters

    result

    result

    index

    index

    type

    sqlite3 column type: SQLITE_INTEGER, SQLITE_FLOAT, SQLITE_STRING, SQLITE_BLOB, or SQLITE_NULL

    dataType

    data type

    Return Value

    value

  • Get the integer value from the result set of the column

    Declaration

    Objective-C

    + (NSObject *)integerValueInResult:(GPKGResultSet *)result
                               atIndex:(int)index
                          withDataType:(enum GPKGDataType)dataType;

    Swift

    class func integerValue(inResult result: GPKGResultSet!, at index: Int32, with dataType: GPKGDataType) -> NSObject!

    Parameters

    result

    result

    index

    index

    dataType

    data type

    Return Value

    integer value

  • Get the float value from the result set of the column

    Declaration

    Objective-C

    + (NSObject *)floatValueInResult:(GPKGResultSet *)result
                             atIndex:(int)index
                        withDataType:(enum GPKGDataType)dataType;

    Swift

    class func floatValue(inResult result: GPKGResultSet!, at index: Int32, with dataType: GPKGDataType) -> NSObject!

    Parameters

    result

    result

    index

    index

    dataType

    data type

    Return Value

    float value

  • Get the converted value from the value and data type

    Declaration

    Objective-C

    + (NSObject *)value:(NSObject *)value asDataType:(enum GPKGDataType)dataType;

    Swift

    class func value(_ value: NSObject!, as dataType: GPKGDataType) -> NSObject!

    Parameters

    value

    object value

    dataType

    data type

    Return Value

    object

  • Min on the database table column where

    Declaration

    Objective-C

    + (NSNumber *)minWithDatabase:(GPKGDbConnection *)connection
                         andTable:(NSString *)table
                        andColumn:(NSString *)column;

    Swift

    class func min(withDatabase connection: GPKGDbConnection!, andTable table: String!, andColumn column: String!) -> NSNumber!

    Parameters

    connection

    connection

    table

    table

    column

    column

    Return Value

    min or nil

  • Min on the database table column where

    Declaration

    Objective-C

    + (NSNumber *)minWithDatabase:(GPKGDbConnection *)connection
                         andTable:(NSString *)table
                        andColumn:(NSString *)column
                         andWhere:(NSString *)where
                     andWhereArgs:(NSArray *)whereArgs;

    Swift

    class func min(withDatabase connection: GPKGDbConnection!, andTable table: String!, andColumn column: String!, andWhere where: String!, andWhereArgs whereArgs: [Any]!) -> NSNumber!

    Parameters

    connection

    connection

    table

    table

    column

    column

    where

    where clause

    whereArgs

    where args

    Return Value

    min or nil

  • Max on the database table column where

    Declaration

    Objective-C

    + (NSNumber *)maxWithDatabase:(GPKGDbConnection *)connection
                         andTable:(NSString *)table
                        andColumn:(NSString *)column;

    Swift

    class func max(withDatabase connection: GPKGDbConnection!, andTable table: String!, andColumn column: String!) -> NSNumber!

    Parameters

    connection

    connection

    table

    table

    column

    column

    Return Value

    max or nil

  • Max on the database table column where

    Declaration

    Objective-C

    + (NSNumber *)maxWithDatabase:(GPKGDbConnection *)connection
                         andTable:(NSString *)table
                        andColumn:(NSString *)column
                         andWhere:(NSString *)where
                     andWhereArgs:(NSArray *)whereArgs;

    Swift

    class func max(withDatabase connection: GPKGDbConnection!, andTable table: String!, andColumn column: String!, andWhere where: String!, andWhereArgs whereArgs: [Any]!) -> NSNumber!

    Parameters

    connection

    connection

    table

    table

    column

    column

    where

    where clause

    whereArgs

    where args

    Return Value

    max or nil

  • Insert into database

    Declaration

    Objective-C

    + (long long)insertWithDatabase:(GPKGDbConnection *)connection
                       andStatement:(NSString *)statement;

    Swift

    class func insert(withDatabase connection: GPKGDbConnection!, andStatement statement: String!) -> Int64

    Parameters

    connection

    connection

    statement

    insert statement

    Return Value

    insertion id

  • Insert into database

    Declaration

    Objective-C

    + (long long)insertWithDatabase:(GPKGDbConnection *)connection
                           andTable:(NSString *)table
                          andValues:(GPKGContentValues *)values;

    Swift

    class func insert(withDatabase connection: GPKGDbConnection!, andTable table: String!, andValues values: GPKGContentValues!) -> Int64

    Parameters

    connection

    connection

    table

    table

    values

    values

    Return Value

    insertion id

  • Update in the database

    Declaration

    Objective-C

    + (int)updateWithDatabase:(GPKGDbConnection *)connection
                 andStatement:(NSString *)statement;

    Swift

    class func update(withDatabase connection: GPKGDbConnection!, andStatement statement: String!) -> Int32

    Parameters

    connection

    connection

    statement

    update statement

    Return Value

    updated rows

  • Update in the database

    Declaration

    Objective-C

    + (int)updateWithDatabase:(GPKGDbConnection *)connection
                 andStatement:(NSString *)statement
                      andArgs:(NSArray *)args;

    Swift

    class func update(withDatabase connection: GPKGDbConnection!, andStatement statement: String!, andArgs args: [Any]!) -> Int32

    Parameters

    connection

    connection

    statement

    update statement

    args

    statement args

    Return Value

    updated rows

  • Update in the database

    Declaration

    Objective-C

    + (int)updateWithDatabase:(GPKGDbConnection *)connection
                     andTable:(NSString *)table
                    andValues:(GPKGContentValues *)values
                     andWhere:(NSString *)where;

    Swift

    class func update(withDatabase connection: GPKGDbConnection!, andTable table: String!, andValues values: GPKGContentValues!, andWhere where: String!) -> Int32

    Parameters

    connection

    connection

    table

    table

    values

    content values

    where

    where clause

    Return Value

    updated rows

  • Update in the database

    Declaration

    Objective-C

    + (int)updateWithDatabase:(GPKGDbConnection *)connection
                     andTable:(NSString *)table
                    andValues:(GPKGContentValues *)values
                     andWhere:(NSString *)where
                 andWhereArgs:(NSArray *)whereArgs;

    Swift

    class func update(withDatabase connection: GPKGDbConnection!, andTable table: String!, andValues values: GPKGContentValues!, andWhere where: String!, andWhereArgs whereArgs: [Any]!) -> Int32

    Parameters

    connection

    connection

    table

    table

    values

    content values

    where

    where clause

    whereArgs

    wher args

    Return Value

    updated rows

  • Delete from the database

    Declaration

    Objective-C

    + (int)deleteWithDatabase:(GPKGDbConnection *)connection
                 andStatement:(NSString *)statement;

    Swift

    class func delete(withDatabase connection: GPKGDbConnection!, andStatement statement: String!) -> Int32

    Parameters

    connection

    connection

    statement

    statement

    Return Value

    deleted rows

  • Delete from the database

    Declaration

    Objective-C

    + (int)deleteWithDatabase:(GPKGDbConnection *)connection
                 andStatement:(NSString *)statement
                      andArgs:(NSArray *)args;

    Swift

    class func delete(withDatabase connection: GPKGDbConnection!, andStatement statement: String!, andArgs args: [Any]!) -> Int32

    Parameters

    connection

    connection

    statement

    statement

    args

    statement args

    Return Value

    deleted rows

  • Delete from the database

    Declaration

    Objective-C

    + (int)deleteWithDatabase:(GPKGDbConnection *)connection
                     andTable:(NSString *)table
                     andWhere:(NSString *)where;

    Swift

    class func delete(withDatabase connection: GPKGDbConnection!, andTable table: String!, andWhere where: String!) -> Int32

    Parameters

    connection

    connection

    table

    table

    where

    where clause

    Return Value

    deleted rows

  • Delete from the database

    Declaration

    Objective-C

    + (int)deleteWithDatabase:(GPKGDbConnection *)connection
                     andTable:(NSString *)table
                     andWhere:(NSString *)where
                 andWhereArgs:(NSArray *)whereArgs;

    Swift

    class func delete(withDatabase connection: GPKGDbConnection!, andTable table: String!, andWhere where: String!, andWhereArgs whereArgs: [Any]!) -> Int32

    Parameters

    connection

    connection

    table

    table

    where

    where clause

    whereArgs

    where args

    Return Value

    deleted rows

  • Close the statement

    Declaration

    Objective-C

    + (void)closeStatement:(sqlite3_stmt *)statement;

    Swift

    class func closeStatement(_ statement: OpaquePointer!)

    Parameters

    statement

    statement

  • Close the result set

    Declaration

    Objective-C

    + (void)closeResultSet:(GPKGResultSet *)resultSet;

    Swift

    class func close(_ resultSet: GPKGResultSet!)

    Parameters

    resultSet

    result set

  • Close the database

    Declaration

    Objective-C

    + (void)closeDatabase:(GPKGSqliteConnection *)connection;

    Swift

    class func closeDatabase(_ connection: GPKGSqliteConnection!)

    Parameters

    connection

    connection

  • Get the sql string for the value

    Declaration

    Objective-C

    + (NSString *)sqlValueString:(NSObject *)value;

    Swift

    class func sqlValueString(_ value: NSObject!) -> String!

    Parameters

    value

    value

    Return Value

    sql string

  • Wrap the name in double quotes

    Declaration

    Objective-C

    + (NSString *)quoteWrapName:(NSString *)name;

    Swift

    class func quoteWrapName(_ name: String!) -> String!

    Parameters

    name

    name

    Return Value

    quoted name

  • Wrap the names in double quotes

    Declaration

    Objective-C

    + (NSArray *)quoteWrapNames:(NSArray *)names;

    Swift

    class func quoteWrapNames(_ names: [Any]!) -> [Any]!

    Parameters

    names

    names

    Return Value

    quoted names

  • Remove double quotes from the name

    Declaration

    Objective-C

    + (NSString *)quoteUnwrapName:(NSString *)name;

    Swift

    class func quoteUnwrapName(_ name: String!) -> String!

    Parameters

    name

    name

    Return Value

    unquoted names

  • Create the user defined table SQL

    Declaration

    Objective-C

    + (NSString *)createTableSQL:(GPKGUserTable *)table;

    Swift

    class func createTableSQL(_ table: GPKGUserTable!) -> String!

    Parameters

    table

    user table

    Return Value

    create table SQL

  • Create the column SQL in the format:

    “column_name” column_type[(max)] [NOT NULL] [PRIMARY KEY AUTOINCREMENT]

    Declaration

    Objective-C

    + (NSString *)columnSQL:(GPKGUserColumn *)column;

    Swift

    class func columnSQL(_ column: GPKGUserColumn!) -> String!

    Parameters

    column

    user column

    Return Value

    column SQL

  • Create the column definition SQL in the format:

    column_type[(max)] [NOT NULL] [PRIMARY KEY AUTOINCREMENT]

    Declaration

    Objective-C

    + (NSString *)columnDefinition:(GPKGUserColumn *)column;

    Swift

    class func columnDefinition(_ column: GPKGUserColumn!) -> String!

    Parameters

    column

    user column

    Return Value

    column definition SQL

  • Get the column default value as a string

    Declaration

    Objective-C

    + (NSString *)columnDefaultValue:(GPKGUserColumn *)column;

    Swift

    class func columnDefaultValue(_ column: GPKGUserColumn!) -> String!

    Parameters

    column

    user column

    Return Value

    default value

  • Get the column default value as a string

    Declaration

    Objective-C

    + (NSString *)columnDefaultValue:(NSObject *)defaultValue
                            withType:(enum GPKGDataType)dataType;

    Swift

    class func columnDefaultValue(_ defaultValue: NSObject!, with dataType: GPKGDataType) -> String!

    Parameters

    defaultValue

    default value

    dataType

    data type

    Return Value

    default value

  • Add a column to a table

    Declaration

    Objective-C

    + (void)addColumn:(GPKGUserColumn *)column
               toTable:(NSString *)tableName
        withConnection:(GPKGConnection *)db;

    Swift

    class func add(_ column: GPKGUserColumn!, toTable tableName: String!, with db: GPKGConnection!)

    Parameters

    column

    user column

    tableName

    table name

    db

    connection

  • Query for the foreign keys value

    Declaration

    Objective-C

    + (BOOL)foreignKeysWithConnection:(GPKGConnection *)db;

    Swift

    class func foreignKeys(with db: GPKGConnection!) -> Bool

    Parameters

    db

    connection

    Return Value

    true if enabled, false if disabled

  • Change the foreign keys state

    Declaration

    Objective-C

    + (BOOL)foreignKeysAsOn:(BOOL)on withConnection:(GPKGConnection *)db;

    Swift

    class func foreignKeysAs(on: Bool, with db: GPKGConnection!) -> Bool

    Parameters

    on

    true to turn on, false to turn off

    db

    connection

    Return Value

    previous foreign keys value

  • Create the foreign keys SQL

    Declaration

    Objective-C

    + (NSString *)foreignKeysSQLAsOn:(BOOL)on;

    Swift

    class func foreignKeysSQLAs(on: Bool) -> String!

    Parameters

    on

    true to turn on, false to turn off

    Return Value

    foreign keys SQL

  • Perform a foreign key check

    Declaration

    Objective-C

    + (NSArray<GPKGRow *> *)foreignKeyCheckWithConnection:(GPKGConnection *)db;

    Swift

    class func foreignKeyCheck(with db: GPKGConnection!) -> [GPKGRow]!

    Parameters

    db

    connection

    Return Value

    empty list if valid or violation errors, 4 column values for each violation. see SQLite PRAGMA foreign_key_check

  • Perform a foreign key check

    Declaration

    Objective-C

    + (NSArray<GPKGRow *> *)foreignKeyCheckOnTable:(NSString *)tableName
                                    withConnection:(GPKGConnection *)db;

    Swift

    class func foreignKeyCheck(onTable tableName: String!, with db: GPKGConnection!) -> [GPKGRow]!

    Parameters

    tableName

    table name

    db

    connection

    Return Value

    empty list if valid or violation errors, 4 column values for each violation. see SQLite PRAGMA foreign_key_check

  • Create the foreign key check SQL

    Declaration

    Objective-C

    + (NSString *)foreignKeyCheckSQL;

    Swift

    class func foreignKeyCheckSQL() -> String!

    Return Value

    foreign key check SQL

  • Create the foreign key check SQL

    Declaration

    Objective-C

    + (NSString *)foreignKeyCheckSQLOnTable:(NSString *)tableName;

    Swift

    class func foreignKeyCheckSQL(onTable tableName: String!) -> String!

    Parameters

    tableName

    table name

    Return Value

    foreign key check SQL

  • Create the integrity check SQL

    Declaration

    Objective-C

    + (NSString *)integrityCheckSQL;

    Swift

    class func integrityCheckSQL() -> String!

    Return Value

    integrity check SQL

  • Create the quick check SQL

    Declaration

    Objective-C

    + (NSString *)quickCheckSQL;

    Swift

    class func quickCheckSQL() -> String!

    Return Value

    quick check SQL

  • Drop the table if it exists

    Declaration

    Objective-C

    + (void)dropTable:(NSString *)tableName withConnection:(GPKGConnection *)db;

    Swift

    class func dropTable(_ tableName: String!, with db: GPKGConnection!)

    Parameters

    tableName

    table name

    db

    connection

  • Create the drop table if exists SQL

    Declaration

    Objective-C

    + (NSString *)dropTableSQL:(NSString *)tableName;

    Swift

    class func dropTableSQL(_ tableName: String!) -> String!

    Parameters

    tableName

    table name

    Return Value

    drop table SQL

  • Drop the view if it exists

    Declaration

    Objective-C

    + (void)dropView:(NSString *)viewName withConnection:(GPKGConnection *)db;

    Swift

    class func dropView(_ viewName: String!, with db: GPKGConnection!)

    Parameters

    viewName

    view name

    db

    connection

  • Create the drop view if exists SQL

    Declaration

    Objective-C

    + (NSString *)dropViewSQL:(NSString *)viewName;

    Swift

    class func dropViewSQL(_ viewName: String!) -> String!

    Parameters

    viewName

    view name

    Return Value

    drop view SQL

  • Transfer table content from one table to another

    Declaration

    Objective-C

    + (void)transferTableContent:(GPKGTableMapping *)tableMapping
                  withConnection:(GPKGConnection *)db;

    Swift

    class func transferTableContent(_ tableMapping: GPKGTableMapping!, with db: GPKGConnection!)

    Parameters

    tableMapping

    table mapping

    db

    connection

  • Create insert SQL to transfer table content from one table to another

    Declaration

    Objective-C

    + (NSString *)transferTableContentSQL:(GPKGTableMapping *)tableMapping;

    Swift

    class func transferTableContentSQL(_ tableMapping: GPKGTableMapping!) -> String!

    Parameters

    tableMapping

    table mapping

    Return Value

    transfer SQL

  • Transfer table content to itself with new rows containing a new column value. All rows containing the current column value are inserted as new rows with the new column value.

    Declaration

    Objective-C

    + (void)transferContentInTable:(NSString *)tableName
                          inColumn:(NSString *)columnName
                      withNewValue:(NSObject *)newColumnValue
                   andCurrentValue:(NSObject *)currentColumnValue
                    withConnection:(GPKGConnection *)db;

    Swift

    class func transferContent(inTable tableName: String!, inColumn columnName: String!, withNewValue newColumnValue: NSObject!, andCurrentValue currentColumnValue: NSObject!, with db: GPKGConnection!)

    Parameters

    tableName

    table name

    columnName

    column name

    newColumnValue

    new column value for new rows

    currentColumnValue

    column value for rows to insert as new rows

    db

    connection

  • Transfer table content to itself with new rows containing a new column value. All rows containing the current column value are inserted as new rows with the new column value.

    Declaration

    Objective-C

    + (void)transferContentInTable:(NSString *)tableName
                          inColumn:(NSString *)columnName
                      withNewValue:(NSObject *)newColumnValue
                   andCurrentValue:(NSObject *)currentColumnValue
                       andIdColumn:(NSString *)idColumnName
                    withConnection:(GPKGConnection *)db;

    Swift

    class func transferContent(inTable tableName: String!, inColumn columnName: String!, withNewValue newColumnValue: NSObject!, andCurrentValue currentColumnValue: NSObject!, andIdColumn idColumnName: String!, with db: GPKGConnection!)

    Parameters

    tableName

    table name

    columnName

    column name

    newColumnValue

    new column value for new rows

    currentColumnValue

    column value for rows to insert as new rows

    idColumnName

    id column name

    db

    connection

  • Get an available temporary table name. Starts with prefix_baseName and then continues with prefix#_baseName starting at 1 and increasing.

    Declaration

    Objective-C

    + (NSString *)tempTableNameWithPrefix:(NSString *)prefix
                              andBaseName:(NSString *)baseName
                           withConnection:(GPKGConnection *)db;

    Swift

    class func tempTableName(withPrefix prefix: String!, andBaseName baseName: String!, with db: GPKGConnection!) -> String!

    Parameters

    prefix

    name prefix

    baseName

    base name

    db

    connection

    Return Value

    unused table name

  • Modify the SQL with a name change and the table mapping modifications

    Declaration

    Objective-C

    + (NSString *)modifySQL:(NSString *)sql
                   withName:(NSString *)name
            andTableMapping:(GPKGTableMapping *)tableMapping;

    Swift

    class func modifySQL(_ sql: String!, withName name: String!, andTableMapping tableMapping: GPKGTableMapping!) -> String!

    Parameters

    name

    statement name

    sql

    SQL statement

    tableMapping

    table mapping

    Return Value

    updated SQL, null if SQL contains a deleted column

  • Modify the SQL with a name change and the table mapping modifications

    Declaration

    Objective-C

    + (NSString *)modifySQL:(NSString *)sql
                   withName:(NSString *)name
            andTableMapping:(GPKGTableMapping *)tableMapping
             withConnection:(GPKGConnection *)db;

    Swift

    class func modifySQL(_ sql: String!, withName name: String!, andTableMapping tableMapping: GPKGTableMapping!, with db: GPKGConnection!) -> String!

    Parameters

    name

    statement name

    sql

    SQL statement

    tableMapping

    table mapping

    db

    optional connection, used for SQLite Master name conflict detection

    Return Value

    updated SQL, null if SQL contains a deleted column

  • Modify the SQL with table mapping modifications

    Declaration

    Objective-C

    + (NSString *)modifySQL:(NSString *)sql
           withTableMapping:(GPKGTableMapping *)tableMapping;

    Swift

    class func modifySQL(_ sql: String!, with tableMapping: GPKGTableMapping!) -> String!

    Parameters

    sql

    SQL statement

    tableMapping

    table mapping

    Return Value

    updated SQL, null if SQL contains a deleted column

  • Replace the name (table, column, etc) in the SQL with the replacement. The name must be surrounded by non word characters (i.e. not a subset of another name).

    Declaration

    Objective-C

    + (NSString *)replaceName:(NSString *)name
                        inSQL:(NSString *)sql
              withReplacement:(NSString *)replacement;

    Swift

    class func replaceName(_ name: String!, inSQL sql: String!, withReplacement replacement: String!) -> String!

    Parameters

    name

    name

    sql

    SQL statement

    replacement

    replacement value

    Return Value

    null if not modified, SQL value if replaced at least once

  • Create a new name by replacing a case insensitive value with a new value. If no replacement is done, create a new name in the form name_#, where # is either 2 or one greater than an existing name number suffix.

    Declaration

    Objective-C

    + (NSString *)createName:(NSString *)name
                  andReplace:(NSString *)replace
             withReplacement:(NSString *)replacement;

    Swift

    class func createName(_ name: String!, andReplace replace: String!, withReplacement replacement: String!) -> String!

    Parameters

    name

    current name

    replace

    value to replace

    replacement

    replacement value

    Return Value

    new name

  • Create a new name by replacing a case insensitive value with a new value. If no replacement is done, create a new name in the form name_#, where # is either 2 or one greater than an existing name number suffix. When a db connection is provided, check for conflicting SQLite Master names and increment # until an available name is found.

    Declaration

    Objective-C

    + (NSString *)createName:(NSString *)name
                  andReplace:(NSString *)replace
             withReplacement:(NSString *)replacement
              withConnection:(GPKGConnection *)db;

    Swift

    class func createName(_ name: String!, andReplace replace: String!, withReplacement replacement: String!, with db: GPKGConnection!) -> String!

    Parameters

    name

    current name

    replace

    value to replace

    replacement

    replacement value

    db

    optional connection, used for SQLite Master name conflict detection

    Return Value

    new name

  • Rebuild the GeoPackage, repacking it into a minimal amount of disk space

    Declaration

    Objective-C

    + (void)vacuumWithConnection:(GPKGConnection *)db;

    Swift

    class func vacuum(with db: GPKGConnection!)

    Parameters

    db

    connection

  • Get the BOOL value of the number

    Declaration

    Objective-C

    + (BOOL)boolValueOfNumber:(NSNumber *)number;

    Swift

    class func boolValue(of number: NSNumber!) -> Bool

    Parameters

    number

    BOOL number