Database Overview
Prism ships with a built-in SQLite database layer that talks directly to the C API throughsqlite3.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.
Why SQLite?
SQLite is the most deployed database in the world. For many server applications — APIs, microservices, internal tools — it’s the right choice:- Zero configuration — no separate database process to manage
- Single-file storage — easy backups, easy deployment
- Incredible read performance — faster than client-server databases for most workloads
- ACID compliant — full transaction support
Creating a Database
Basic Setup
In-Memory Database
Creating Tables
Creating a Users Table
Basic CRUD Operations
- Insert
- Query
- Update
- Delete
Insert a Row
Parameter Binding
Always use parameterized queries to prevent SQL injection:Safe Parameter Binding
Transactions
Group multiple operations into an atomic transaction:Transaction Example
Query Results
PrismRow gives you typed access to column values:
Working with Rows
Using with the Server
Database in Route Handlers
Query Builder
Build queries fluently without writing raw SQL
Models
Map database rows to Swift structs automatically
Migrations
Version your database schema with up/down migrations
Connection Pool
Handle concurrent requests with pooled connections