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
connectionconnection
statementstatement
-
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
connectionconnection
statementstatement
-
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
connectionconnection
statementstatement
argsstatement args
Return Value
result set
-
+queryWithDatabase:andDistinct: andTable: andColumns: andWhere: andWhereArgs: andGroupBy: andHaving: andOrderBy: andLimit: 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
connectionconnection
distinctdistinct flag
tabletable
columnscolumns
wherewhere clause
whereArgswhere args
groupBygroup by clause
havinghaving clause
orderByorder by clause
limitlimit 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
distinctdistinct flag
tabletable
columnscolumns
wherewhere clause
groupBygroup by clause
havinghaving clause
orderByorder by clause
limitlimit 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]!) -> Int32Parameters
connectionconnection
statementcount statement
argsstatement 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!) -> Int32Parameters
connectionconnection
tabletable
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!) -> Int32Parameters
connectionconnection
tabletable
wherewhere 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]!) -> Int32Parameters
connectionconnection
tabletable
wherewhere clause
whereArgswhere 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!) -> Int32Parameters
connectiondatabase connection
countStatementcount 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]!) -> Int32Parameters
connectionconnection
countStatementcount statement
argsstatement 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!) -> Int32Parameters
connectionconnection
tabletable name
columncolumn 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!) -> Int32Parameters
connectionconnection
tabletable name
distinctdistinct column flag
columncolumn 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]!) -> Int32Parameters
connectionconnection
tabletable name
columncolumn name
wherewhere clause
whereArgsarguments
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]!) -> Int32Parameters
connectionconnection
tabletable name
distinctdistinct column flag
columncolumn name
wherewhere clause
whereArgsarguments
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
connectionconnection
sqlsql statement
argsarguments
columncolumn index
dataTypeGeoPackage 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
connectionconnection
sqlsql statement
argsarguments
columncolumn index
dataTypeGeoPackage data type
limitresult 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
connectionconnection
sqlsql statement
argsarguments
dataTypescolumn data types
limitresult 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
resultresult
indexindex
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
resultresult
indexindex
dataTypedata 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
resultresult
indexindex
typesqlite3 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
resultresult
indexindex
typesqlite3 column type: SQLITE_INTEGER, SQLITE_FLOAT, SQLITE_STRING, SQLITE_BLOB, or SQLITE_NULL
dataTypedata 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
resultresult
indexindex
dataTypedata 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
resultresult
indexindex
dataTypedata 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
valueobject value
dataTypedata 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
connectionconnection
tabletable
columncolumn
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
connectionconnection
tabletable
columncolumn
wherewhere clause
whereArgswhere 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
connectionconnection
tabletable
columncolumn
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
connectionconnection
tabletable
columncolumn
wherewhere clause
whereArgswhere 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!) -> Int64Parameters
connectionconnection
statementinsert 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!) -> Int64Parameters
connectionconnection
tabletable
valuesvalues
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!) -> Int32Parameters
connectionconnection
statementupdate 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]!) -> Int32Parameters
connectionconnection
statementupdate statement
argsstatement 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!) -> Int32Parameters
connectionconnection
tabletable
valuescontent values
wherewhere 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]!) -> Int32Parameters
connectionconnection
tabletable
valuescontent values
wherewhere clause
whereArgswher 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!) -> Int32Parameters
connectionconnection
statementstatement
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]!) -> Int32Parameters
connectionconnection
statementstatement
argsstatement 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!) -> Int32Parameters
connectionconnection
tabletable
wherewhere 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]!) -> Int32Parameters
connectionconnection
tabletable
wherewhere clause
whereArgswhere args
Return Value
deleted rows
-
Close the statement
Declaration
Objective-C
+ (void)closeStatement:(sqlite3_stmt *)statement;Swift
class func closeStatement(_ statement: OpaquePointer!)Parameters
statementstatement
-
Close the result set
Declaration
Objective-C
+ (void)closeResultSet:(GPKGResultSet *)resultSet;Swift
class func close(_ resultSet: GPKGResultSet!)Parameters
resultSetresult set
-
Close the database
Declaration
Objective-C
+ (void)closeDatabase:(GPKGSqliteConnection *)connection;Swift
class func closeDatabase(_ connection: GPKGSqliteConnection!)Parameters
connectionconnection
-
Get the sql string for the value
Declaration
Objective-C
+ (NSString *)sqlValueString:(NSObject *)value;Swift
class func sqlValueString(_ value: NSObject!) -> String!Parameters
valuevalue
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
namename
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
namesnames
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
namename
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
tableuser 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
columnuser 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
columnuser 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
columnuser 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
defaultValuedefault value
dataTypedata 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
columnuser column
tableNametable name
dbconnection
-
Query for the foreign keys value
Declaration
Objective-C
+ (BOOL)foreignKeysWithConnection:(GPKGConnection *)db;Swift
class func foreignKeys(with db: GPKGConnection!) -> BoolParameters
dbconnection
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!) -> BoolParameters
ontrue to turn on, false to turn off
dbconnection
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
ontrue 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
dbconnection
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
tableNametable name
dbconnection
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
tableNametable 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
tableNametable name
dbconnection
-
Create the drop table if exists SQL
Declaration
Objective-C
+ (NSString *)dropTableSQL:(NSString *)tableName;Swift
class func dropTableSQL(_ tableName: String!) -> String!Parameters
tableNametable 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
viewNameview name
dbconnection
-
Create the drop view if exists SQL
Declaration
Objective-C
+ (NSString *)dropViewSQL:(NSString *)viewName;Swift
class func dropViewSQL(_ viewName: String!) -> String!Parameters
viewNameview 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
tableMappingtable mapping
dbconnection
-
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
tableMappingtable 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
tableNametable name
columnNamecolumn name
newColumnValuenew column value for new rows
currentColumnValuecolumn value for rows to insert as new rows
dbconnection
-
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
tableNametable name
columnNamecolumn name
newColumnValuenew column value for new rows
currentColumnValuecolumn value for rows to insert as new rows
idColumnNameid column name
dbconnection
-
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
prefixname prefix
baseNamebase name
dbconnection
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
namestatement name
sqlSQL statement
tableMappingtable 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
namestatement name
sqlSQL statement
tableMappingtable mapping
dboptional 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
sqlSQL statement
tableMappingtable 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
namename
sqlSQL statement
replacementreplacement 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
namecurrent name
replacevalue to replace
replacementreplacement 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
namecurrent name
replacevalue to replace
replacementreplacement value
dboptional 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
dbconnection
-
Get the BOOL value of the number
Declaration
Objective-C
+ (BOOL)boolValueOfNumber:(NSNumber *)number;Swift
class func boolValue(of number: NSNumber!) -> BoolParameters
numberBOOL number
View on GitHub
GPKGSqlUtils Class Reference