SwiftSQLite
sqlite3 的轻量级 Swift 封装
示例
import SwiftSQLite
let sqlite = try! SQLite(path: "test.db")
try! sqlite.query("CREATE TABLE test (id INTEGER PRIMARY KEY AUTOINCREMENT, value TEXT)")
try! sqlite.query("INSERT INTO test (value) VALUES (?)", arguments: ["😎"])
try! sqlite.query("INSERT INTO test (value) VALUES (?)", arguments: ["🤪"])
print("Last insert id: \(sqlite.lastInsertRowId)")
// -> Last insert id: 2
let result = try! sqlite.query("SELECT * FROM test")
print(result.fetchAll(column: "value") as [String])
// -> ["😎", "🤪"]
文档
请参阅单元测试以了解用法。在 文档 目录中找到参考文档。