SQLiteManager

public final class SQLiteManager

The main class of the SQLite Manager

  • db

    Undocumented

    Declaration

    Swift

    internal var db: OpaquePointer?
  • log

    Undocumented

    Declaration

    Swift

    internal let log: OSLog
  • Undocumented

    Declaration

    Swift

    internal let isLoggingEnabled: Bool
  • To initialize the SQLite Manager

    Declaration

    Swift

    public init(path: String, isLoggingEnabled: Bool = false) throws

    Parameters

    path

    A String with a path to the database

    isLoggingEnabled

    TRUE Logging is enabled with os.log and FALSE (Standard) disable the logging

  • To copy the database to the working folder

    Declaration

    Swift

    public func copyDatabaseToTarget(sourceFilePath: URL, targetPath: URL) throws

    Parameters

    sourcFilePath

    The path of the sqlite database file with the filename as a URL

    targetPath

    The working folder for the local sqlite database as a URL

  • To run the query in the SQLite database with optional parameters

    Declaration

    Swift

    public func query(sql: String, parameters: [Any] = []) -> AnyPublisher<[[String : Any]], Error>

    Parameters

    sql

    The sql command in a string

    perameters

    An Array of integer and String values (optional)

    Return Value

    A Combine any publisher with the result of the query or the error

  • To write the logging error message with os.log

    Declaration

    Swift

    internal func logError(_ message: String)

    Parameters

    message

    The error message as a string

  • To close the database if the SQLite manager was deinitialize

    Declaration

    Swift

    deinit
  • To check if the entry exists in the table

    Declaration

    Swift

    public func checkEntryExistsInColumn(inTable table: String, inColumn column: String, entry: String) -> AnyPublisher<Bool, Error>

    Parameters

    table

    The name of the database table as a string

    column

    The column name for check the entry

    entry

    The content of the row as a string

    Return Value

    A Combine any publisher returns TRUE if the entry exists in the table, otherwise FALSE.

  • To check if the entry exists in the primary key column

    Declaration

    Swift

    public func checkEntryExists(inTable table: String, primaryKeyValue: Any) -> AnyPublisher<Bool, Error>