Skip to content

DavidSkrundz/SQLite

Repository files navigation

SQLite Swift Version Platforms Build Status Codebeat Status Codecov

A (currently limited) Swift wrapper for sqlite

Use

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 ?? "")

Supported Types

Currently all returned values are String, but Ints and Doubles can be gotten and returned from user-defined functions.