A Swift toolkit for SQLite databases, offering record persistence, a query interface, migrations, and database observation for app development.
stephencelis/SQLite.swift
A type-safe Swift layer over SQLite3 that offers a query builder and typed data access for Apple and Linux apps.
- Stars
- 10,188
- Forks
- 1,612
- Open issues
- 133
- Last commit
- 12 days ago
What is it?
SQLite.swift wraps the SQLite3 C API in a pure-Swift interface. Instead of concatenating SQL strings, developers build queries with a typed expression builder, so column types and optionality are checked by the compiler. Queries are chainable and lazy, running only when executed.
The library also works as a thin, Swift-friendly wrapper over raw SQL when needed, with prepared statements, parameter binding, and access to connection properties such as totalChanges and lastInsertRowid. It includes schema query and migration helpers, full-text search support, WAL journaling configuration, and SQLCipher integration through Swift Package Manager.
It is installable via Swift Package Manager, CocoaPods, Carthage, or as an Xcode sub-project, and it runs on Linux with some limitations.
Key features
- 01Type-safe SQL expression builder with optional-aware column types
- 02Chainable, lazily executed query API
- 03Raw SQL prepared statements with parameter binding
- 04Schema querying and migration helpers
- 05Full-text search and WAL journaling configuration
- 06SQLCipher support via Swift Package Manager
Use cases
- Persisting local data in an iOS or macOS app with compile-time-checked queries
- Building a Swift server or command-line tool that stores data in SQLite on Linux
- Encrypting a local database with SQLCipher in an Apple-platform app
Quick start
- 1
Add the SQLite.swift dependency to Package.swift
- 2
Build your project with Swift Package Manager
swift build
Things to know
- Iterating prepare() results force-tries each step, so SQLite errors mid-iteration crash the app; use prepareRowIterator() to handle them.
- Linux support comes with some limitations.
In collections
Topics
FAQ
- What is SQLite.swift?
- A type-safe Swift layer over SQLite3 that offers a query builder and typed data access for Apple and Linux apps. SQLite.swift wraps the SQLite3 C API in a pure-Swift interface. Instead of concatenating SQL strings, developers build queries with a typed expression builder, so column types and optionality are checked by the compiler. Queries are chainable and lazy, running only when executed.
- Is SQLite.swift free to use? What license does it have?
- SQLite.swift is open source under the MIT license. Check the license terms before using it in commercial products.
- Is SQLite.swift still maintained?
- Actively maintained. The last commit to SQLite.swift was on Oct 25, 2026.
- What can I use SQLite.swift for?
- Persisting local data in an iOS or macOS app with compile-time-checked queries Building a Swift server or command-line tool that stores data in SQLite on Linux Encrypting a local database with SQLCipher in an Apple-platform app
- How do I install SQLite.swift?
- Add the SQLite.swift dependency to Package.swift Build your project with Swift Package Manager: swift build
- Where can I get SQLite.swift?
- The source code and installation instructions are on GitHub: https://github.com/stephencelis/SQLite.swift
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A safe, extensible ORM and query builder for Rust that checks queries at compile time across PostgreSQL, MySQL, SQLite and MariaDB.
TypeScript ORM for Node.js that gives type-safe database access across PostgreSQL, MySQL, SQLite, MongoDB and other databases.
A type-safe TypeScript SQL query builder that autocompletes tables, columns and result types across SQL databases.
A lightweight single-file PHP database framework that simplifies common SQL operations with a clean, intuitive API.
A TypeScript and JavaScript ORM for Node.js and other JS platforms, supporting both Active Record and Data Mapper patterns across many SQL and NoSQL databases.