Prism ships with a built-in SQLite database layer that talks directly to the C API through sqlite3.h. There’s no ORM abstraction tax — you get raw performance with a clean Swift interface, all wrapped in an actor for safe concurrent access.
Prism uses the system SQLite that ships with macOS and Linux. No additional installation needed.
Incredible read performance — faster than client-server databases for most workloads
ACID compliant — full transaction support
SQLite handles thousands of concurrent reads and hundreds of writes per second. For most APIs, that’s more than enough. When you outgrow it, Prism’s PrismDatabase protocol makes it straightforward to swap backends.
try await db.execute(""" CREATE TABLE IF NOT EXISTS users ( id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, email TEXT UNIQUE NOT NULL, created_at TEXT DEFAULT CURRENT_TIMESTAMP )""")
try await db.execute( "INSERT INTO users (name, email) VALUES (?, ?)", parameters: [.text("Alice"), .text("alice@example.com")])let id = await db.lastInsertIDprint("Created user with ID: \(id)")
Query Rows
let users = try await db.query( "SELECT * FROM users WHERE name LIKE ?", parameters: [.text("%Ali%")])for user in users { let name = user["name"]?.textValue ?? "Unknown" let email = user["email"]?.textValue ?? "" print("\(name) — \(email)")}
Update a Row
let affected = try await db.execute( "UPDATE users SET name = ? WHERE id = ?", parameters: [.text("Alice Smith"), .integer(1)])print("Updated \(affected) rows")
Delete a Row
let affected = try await db.execute( "DELETE FROM users WHERE id = ?", parameters: [.integer(1)])print("Deleted \(affected) rows")
let row = try await db.queryFirst("SELECT * FROM users WHERE id = ?", parameters: [.integer(1)])if let user = row { let name = user["name"]?.textValue // String? let age = user["age"]?.intValue // Int? let score = user["score"]?.realValue // Double? let avatar = user["avatar"]?.blobValue // Data?}