A (currently limited) Swift wrapper for sqlite
func some(context: OpaquePointer?,
argc: Int32,
values: UnsafeMutablePointer<OpaquePointer?>?) -> Void {
let value = SQLite.getDouble(values![0])
print("Got \(value)")
SQLite.returnDouble(context, value * 10)
}
let database = Database(fileName: "mydb.sql")
let connection = try database.connect()
connection.createFunction("some", argc: 1, function: some)
let statement = "SELECT some(5);"
let result = connection.unsafeExecute(statement)
print(result ?? "")
Currently all returned values are String, but Ints and Doubles can be gotten and returned from user-defined functions.