GitHub Trends
10.1K subscribers
15.3K links
See what the GitHub community is most excited about today.

A bot automatically fetches new repositories from https://github.com/trending and sends them to the channel.

Author and maintainer: https://github.com/katursis
Download Telegram
#swift #database #database_observation #grdb #spm #sql #sql_builder #sqlite #sqlite_databases

GRDB is a Swift library that helps you interact with SQLite databases in a safe and efficient way. Here’s the key information GRDB allows you to save your application’s permanent data into SQLite databases.
- **SQL Generation** You can get notifications when database values are modified.
- **Robust Concurrency** GRDB helps you evolve the schema of your database as you ship new versions of your application.

### Installation
- You can install GRDB using the Swift Package Manager, CocoaPods, or Carthage (though Carthage is unsupported).

### Usage
- Open a database connection using `DatabaseQueue` or `DatabasePool`.
- Define your database schema and create tables.
- Use the `FetchableRecord`, `TableRecord`, and `PersistableRecord` protocols to define your record types.
- Fetch records using methods like `fetchCursor`, `fetchAll`, `fetchSet`, and `fetchOne`.
- Perform CRUD operations (Create, Read, Update, Delete) using methods like `insert`, `update`, `save`, and `delete`.

### Query Interface
- GRDB provides a query interface that lets you write pure Swift instead of SQL.
- You can filter, order, limit, and join records using chainable methods.
- It supports associations and joins.

### Records
- Records are your application objects that can initialize themselves from rows.
- You can define record types using protocols like `FetchableRecord`, `TableRecord`, and `PersistableRecord`.
- Records can be compared against other records or previous versions to avoid unnecessary updates.

### Error Handling
- GRDB throws `DatabaseError` and `RecordError` for various issues.
- It also uses fatal errors to indicate programmer errors or misuses.
- You can configure error logging and tracing to monitor database operations.

### Encryption
- GRDB supports encryption using SQLCipher.
- You can create or open an encrypted database by providing a passphrase.

### Backup and Interruption
- You can backup a database into another.
- The `interrupt` method can cause any pending database operation to abort.

### FAQ
- GRDB provides answers to common questions about opening connections, SQL queries, general usage, associations,

https://github.com/groue/GRDB.swift