![GRDB: A toolkit for SQLite databases, with a focus on application development](https://raw.githubusercontent.com/groue/GRDB.swift/master/GRDB.png)
<p align="center"><strong>A toolkit for SQLite databases, with a focus on application development</strong></p>
<p align="center">
<a href="https://developer.apple.com/swift/"><img alt="Swift 5.2" src="https://img.shields.io/badge/swift-5.2-orange.svg?style=flat"></a>
<a href="https://developer.apple.com/swift/"><img alt="Platforms" src="https://img.shields.io/cocoapods/p/GRDB.swift.svg"></a>
<a href="https://github.com/groue/GRDB.swift/blob/master/LICENSE"><img alt="License" src="https://img.shields.io/github/license/groue/GRDB.swift.svg?maxAge=2592000"></a>
<a href="https://travis-ci.org/groue/GRDB.swift"><img alt="Build Status" src="https://travis-ci.org/groue/GRDB.swift.svg?branch=master"></a>
</p>
---
**Latest release**: April 11, 2021 • version 5.7.4 • [CHANGELOG](CHANGELOG.md) • [Migrating From GRDB 4 to GRDB 5](Documentation/GRDB5MigrationGuide.md)
**Requirements**: iOS 10.0+ / macOS 10.10+ / tvOS 9.0+ / watchOS 2.0+ • SQLite 3.8.5+ • Swift 5.2+ / Xcode 11.4+
| Swift version | GRDB version |
| -------------- | ----------------------------------------------------------- |
| **Swift 5.2+** | **v5.7.4** |
| Swift 5.1 | [v4.14.0](https://github.com/groue/GRDB.swift/tree/v4.14.0) |
| Swift 5 | [v4.14.0](https://github.com/groue/GRDB.swift/tree/v4.14.0) |
| Swift 4.2 | [v4.14.0](https://github.com/groue/GRDB.swift/tree/v4.14.0) |
| Swift 4.1 | [v3.7.0](https://github.com/groue/GRDB.swift/tree/v3.7.0) |
| Swift 4 | [v2.10.0](https://github.com/groue/GRDB.swift/tree/v2.10.0) |
| Swift 3.2 | [v1.3.0](https://github.com/groue/GRDB.swift/tree/v1.3.0) |
| Swift 3.1 | [v1.3.0](https://github.com/groue/GRDB.swift/tree/v1.3.0) |
| Swift 3 | [v1.0](https://github.com/groue/GRDB.swift/tree/v1.0) |
| Swift 2.3 | [v0.81.2](https://github.com/groue/GRDB.swift/tree/v0.81.2) |
| Swift 2.2 | [v0.80.2](https://github.com/groue/GRDB.swift/tree/v0.80.2) |
**Contact**:
- Release announcements and usage tips: follow [@groue](http://twitter.com/groue) on Twitter.
- Report bugs in a [Github issue](https://github.com/groue/GRDB.swift/issues/new). Make sure you check the [existing issues](https://github.com/groue/GRDB.swift/issues?q=is%3Aopen) first.
- A question? Looking for advice? Do you wonder how to contribute? Fancy a chat? Go to the [GRDB forums](https://forums.swift.org/c/related-projects/grdb), or open a [Github issue](https://github.com/groue/GRDB.swift/issues/new).
## What is this?
GRDB provides raw access to SQL and advanced SQLite features, because one sometimes enjoys a sharp tool. It has robust concurrency primitives, so that multi-threaded applications can efficiently use their databases. It grants your application models with persistence and fetching methods, so that you don't have to deal with SQL and raw database rows when you don't want to.
Compared to [SQLite.swift](http://github.com/stephencelis/SQLite.swift) or [FMDB](http://github.com/ccgus/fmdb), GRDB can spare you a lot of glue code. Compared to [Core Data](https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CoreData/) or [Realm](http://realm.io), it can simplify your multi-threaded applications.
It comes with [up-to-date documentation](#documentation), [general guides](#general-guides--good-practices), and it is [fast](https://github.com/groue/GRDB.swift/wiki/Performance).
See [Why Adopt GRDB?](Documentation/WhyAdoptGRDB.md) if you are looking for your favorite database library.
---
<p align="center">
<a href="#features">Features</a> •
<a href="#usage">Usage</a> •
<a href="#installation">Installation</a> •
<a href="#documentation">Documentation</a> •
<a href="#faq">FAQ</a>
</p>
---
## Features
GRDB ships with:
- [Access to raw SQL and SQLite](#sqlite-api)
- [Records](#records): Fetching and persistence methods for your custom structs and class hierarchies.
- [Query Interface](#the-query-interface): A swift way to avoid the SQL language.
- [Associations]: Relations and joins between record types.
- [WAL Mode Support](#database-pools): Extra performance for multi-threaded applications.
- [Migrations]: Transform your database as your application evolves.
- [Database Observation]: Observe database changes and transactions.
- [Combine Support]: Access and observe the database with Combine publishers.
- [RxSwift Support](http://github.com/RxSwiftCommunity/RxGRDB): Access and observe the database with RxSwift observables.
- [Full-Text Search]
- [Encryption](#encryption)
- [Support for Custom SQLite Builds](Documentation/CustomSQLiteBuilds.md)
## Usage
<details open>
<summary>Start using the database in four easy steps</summary>
```swift
import GRDB
// 1. Open a database connection
let dbQueue = try DatabaseQueue(path: "/path/to/database.sqlite")
// 2. Define the database schema
try dbQueue.write { db in
try db.create(table: "player") { t in
t.autoIncrementedPrimaryKey("id")
t.column("name", .text).notNull()
t.column("score", .integer).notNull()
}
}
// 3. Define a record type
struct Player: Codable, FetchableRecord, PersistableRecord {
var id: Int64
var name: String
var score: Int
}
// 4. Access the database
try dbQueue.write { db in
try Player(id: 1, name: "Arthur", score: 100).insert(db)
try Player(id: 2, name: "Barbara", score: 1000).insert(db)
}
let players: [Player] = try dbQueue.read { db in
try Player.fetchAll(db)
}
```
</details>
<details>
<summary>Activate the WAL mode</summary>
```swift
import GRDB
// Simple database connection
let dbQueue = try DatabaseQueue(path: "/path/to/database.sqlite")
// Enhanced multithreading based on SQLite's WAL mode
let dbPool = try DatabasePool(path: "/path/to/database.sqlite")
```
See [Database Connections](#database-connections)
</details>
<details>
<summary>Access to raw SQL</summary>
```swift
try dbQueue.write { db in
try db.execute(sql: """
CREATE TABLE place (
id INTEGER PRIMARY KEY AUTOINCREMENT,
title TEXT NOT NULL,
favorite BOOLEAN NOT NULL DEFAULT 0,
latitude DOUBLE NOT NULL,
longitude DOUBLE NOT NULL)
""")
try db.execute(sql: """
INSERT INTO place (title, favorite, latitude, longitude)
VALUES (?, ?, ?, ?)
""", arguments: ["Paris", true, 48.85341, 2.3488])
let parisId = db.lastInsertedRowID
// Avoid SQL injection with SQL interpolation
try db.execute(literal: """
INSERT INTO place (title, favorite, latitude, longitude)
VALUES (\("King's Cross"), \(true), \(51.52151), \(-0.12763))
""")
}
```
See [Executing Updates](#executing-updates)
</details>
<details>
<summary>Access to raw database rows and values</summary>
```swift
try dbQueue.read { db in
// Fetch database rows
let rows = try Row.fetchCursor(db, sql: "SELECT * FROM place")
while let row = try rows.next() {
let title: String = row["title"]
let isFavorite: Bool = row["favorite"]
let coordinate = CLLocationCoordinate2D(
latitude: row["latitude"],
longitude: row["longitude"])
}
// Fetch values
let placeCount = try Int.fetchOne(db, sql: "SELECT COUNT(*) FROM place")! // Int
let placeTitles = try String.fetchAll(db, sql: "SELECT title FROM place") // [String]
}
let placeCount = try dbQueue.read { db in
try Int.fetchOne(db, sql: "SELECT COUNT(*) FROM place")!
}
```
See [Fetch Queries](#fetch-queries)
</details>
<details>
<summary>Database model types aka "records"</summary>
```swift
struct Place {
var id: Int64?
var title: String
var isFavor
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Swift项目,记账项目代码.zip (1913个子文件)
.gitignore 2KB
grdb_config.h 2KB
Pods-TestSwiftDemo-umbrella.h 328B
GRDB.swift-umbrella.h 324B
ObjectMapper-umbrella.h 316B
SwiftyJSON-umbrella.h 312B
SnapKit-umbrella.h 306B
Contents.json 2KB
Contents.json 402B
Contents.json 379B
Contents.json 378B
Contents.json 378B
Contents.json 378B
Contents.json 378B
Contents.json 372B
Contents.json 369B
Contents.json 369B
Contents.json 367B
Contents.json 367B
Contents.json 365B
Contents.json 365B
Contents.json 363B
Contents.json 361B
Contents.json 361B
Contents.json 361B
Contents.json 359B
Contents.json 359B
Contents.json 359B
Contents.json 359B
Contents.json 359B
Contents.json 359B
Contents.json 357B
Contents.json 357B
Contents.json 357B
Contents.json 357B
Contents.json 355B
Contents.json 355B
Contents.json 355B
Contents.json 355B
Contents.json 355B
Contents.json 355B
Contents.json 355B
Contents.json 353B
Contents.json 353B
Contents.json 353B
Contents.json 353B
Contents.json 353B
Contents.json 353B
Contents.json 351B
Contents.json 351B
Contents.json 351B
Contents.json 351B
Contents.json 351B
Contents.json 351B
Contents.json 351B
Contents.json 351B
Contents.json 351B
Contents.json 351B
Contents.json 351B
Contents.json 351B
Contents.json 351B
Contents.json 351B
Contents.json 349B
Contents.json 349B
Contents.json 347B
Contents.json 347B
Contents.json 347B
Contents.json 345B
Contents.json 341B
Contents.json 335B
Contents.json 335B
Contents.json 335B
Contents.json 335B
Contents.json 333B
Contents.json 333B
Contents.json 332B
Contents.json 332B
Contents.json 331B
Contents.json 331B
Contents.json 331B
Contents.json 331B
Contents.json 330B
Contents.json 330B
Contents.json 330B
Contents.json 330B
Contents.json 330B
Contents.json 330B
Contents.json 330B
Contents.json 330B
Contents.json 330B
Contents.json 329B
Contents.json 329B
Contents.json 329B
Contents.json 329B
Contents.json 329B
Contents.json 329B
Contents.json 329B
Contents.json 329B
Contents.json 329B
Contents.json 329B
共 1913 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
yava_free
- 粉丝: 3653
- 资源: 1458
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- C语言-leetcode题解之83-remove-duplicates-from-sorted-list.c
- C语言-leetcode题解之79-word-search.c
- C语言-leetcode题解之78-subsets.c
- C语言-leetcode题解之75-sort-colors.c
- C语言-leetcode题解之74-search-a-2d-matrix.c
- C语言-leetcode题解之73-set-matrix-zeroes.c
- 树莓派物联网智能家居基础教程
- YOLOv5深度学习目标检测基础教程
- (源码)基于Arduino和Nextion的HMI人机界面系统.zip
- (源码)基于 JavaFX 和 MySQL 的影院管理系统.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功