A type-safe Swift layer over SQLite3 that offers a query builder and typed data access for Apple and Linux apps.
groue/GRDB.swift
A Swift toolkit for SQLite databases, offering record persistence, a query interface, migrations, and database observation for app development.
- Stars
- 8,726
- Forks
- 1,104
- Open issues
- 14
- Last commit
- yesterday
What is it?
GRDB.swift is a Swift library for saving application data into SQLite databases. It lets you map Swift structs and classes to tables with fetch and persistence methods, so you can avoid writing SQL and handling raw rows for common operations, while still writing raw SQL when needed.
The library provides a Swift query interface for building requests, a migration system for evolving a schema across app releases, and full-text search support. Database observation sends notifications when stored values change, with ready-made integration for Swift concurrency, Combine, and RxSwift. Database connections come as DatabaseQueue or DatabasePool, the latter using WAL mode to allow concurrent reads and writes.
GRDB supports iOS, macOS, tvOS and watchOS and is installed through Swift Package Manager, CocoaPods, or manually. Companion libraries cover SwiftUI integration and snapshot testing of database contents.
Key features
- 01Map Swift structs and classes to tables with built-in fetch and persistence methods.
- 02Swift query interface for building SQL requests, plus raw SQL with safe argument binding.
- 03Schema migrations to evolve the database across app versions.
- 04Database observation that notifies on changes, with Combine, RxSwift and async sequence support.
- 05DatabaseQueue and DatabasePool connection types, with WAL mode for concurrent reads and writes.
- 06Full-text search and optional SQLCipher encryption.
Use cases
- Persisting user data and models in an iOS or macOS app.
- Observing database changes to keep SwiftUI or UIKit views up to date.
- Managing schema changes across successive app releases with migrations.
- Building offline-first apps that store data locally in SQLite.
Quick start
- 1
Add GRDB to your project with Swift Package Manager using the repository URL
- 2
Import GRDB and open a database connection
Things to know
- Targets Apple platforms (iOS, macOS, tvOS, watchOS) and requires Swift 6.1 or later.
- Carthage is unsupported, and CocoaPods cannot receive new versions, so later releases need a git branch or tag workaround.
In collections
Topics
FAQ
- What is GRDB.swift?
- A Swift toolkit for SQLite databases, offering record persistence, a query interface, migrations, and database observation for app development. GRDB.swift is a Swift library for saving application data into SQLite databases. It lets you map Swift structs and classes to tables with fetch and persistence methods, so you can avoid writing SQL and handling raw rows for common operations, while still writing raw SQL when needed.
- Is GRDB.swift free to use? What license does it have?
- GRDB.swift is open source under the MIT license. Check the license terms before using it in commercial products.
- Is GRDB.swift still maintained?
- Actively maintained. The last commit to GRDB.swift was on Nov 5, 2026.
- What can I use GRDB.swift for?
- Persisting user data and models in an iOS or macOS app. Observing database changes to keep SwiftUI or UIKit views up to date. Managing schema changes across successive app releases with migrations. Building offline-first apps that store data locally in SQLite.
- How do I install GRDB.swift?
- Add GRDB to your project with Swift Package Manager using the repository URL Import GRDB and open a database connection
- Where can I get GRDB.swift?
- The source code and installation instructions are on GitHub: https://github.com/groue/GRDB.swift
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
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.
A safe, extensible ORM and query builder for Rust that checks queries at compile time across PostgreSQL, MySQL, SQLite and MariaDB.
A Swift library that wraps Apple's Core Data with a type-safe, concurrency-safe API for iOS, macOS, watchOS and tvOS apps.
A Swift package for calling OpenAI's public API across Apple platforms and Linux, with support for many OpenAI-compatible providers.
A free, open source native database client for macOS and iOS supporting SQL and NoSQL databases, with built-in AI chat and an MCP server.