|
| 1 | +<p align="center"> |
| 2 | + <a href="https://tur.so/turso-swift"> |
| 3 | + <picture> |
| 4 | + <img src="/.github/cover.png" alt="libSQL Swift" /> |
| 5 | + </picture> |
| 6 | + </a> |
| 7 | + <h1 align="center">libSQL Swift</h1> |
| 8 | +</p> |
| 9 | + |
| 10 | +<p align="center"> |
| 11 | + Databases for Swift multi-tenant AI Apps. |
| 12 | +</p> |
| 13 | + |
| 14 | +<p align="center"> |
| 15 | + <a href="https://tur.so/turso-swift"><strong>Turso</strong></a> · |
| 16 | + <a href="https://docs.turso.tech"><strong>Docs</strong></a> · |
| 17 | + <a href="https://docs.turso.tech/sdk/swift/quickstart"><strong>Quickstart</strong></a> · |
| 18 | + <a href="https://docs.turso.tech/sdk/swift/reference"><strong>SDK Reference</strong></a> · |
| 19 | + <a href="https://turso.tech/blog"><strong>Blog & Tutorials</strong></a> |
| 20 | +</p> |
| 21 | + |
| 22 | +<p align="center"> |
| 23 | + <a href="LICENSE"> |
| 24 | + <picture> |
| 25 | + <img src="https://img.shields.io/github/license/tursodatabase/libsql-swift?color=0F624B" alt="MIT License" /> |
| 26 | + </picture> |
| 27 | + </a> |
| 28 | + <a href="https://tur.so/discord-swift"> |
| 29 | + <picture> |
| 30 | + <img src="https://img.shields.io/discord/933071162680958986?color=0F624B" alt="Discord" /> |
| 31 | + </picture> |
| 32 | + </a> |
| 33 | + <a href="#contributors"> |
| 34 | + <picture> |
| 35 | + <img src="https://img.shields.io/github/contributors/tursodatabase/libsql-swift?color=0F624B" alt="Contributors" /> |
| 36 | + </picture> |
| 37 | + </a> |
| 38 | + <a href="/examples"> |
| 39 | + <picture> |
| 40 | + <img src="https://img.shields.io/badge/browse-examples-0F624B" alt="Examples" /> |
| 41 | + </picture> |
| 42 | + </a> |
| 43 | +</p> |
| 44 | + |
| 45 | +## Features |
| 46 | + |
| 47 | +- 🔌 Works offline with [Embedded Replicas](https://docs.turso.tech/features/embedded-replicas/introduction) |
| 48 | +- 🌎 Works with remote Turso databases |
| 49 | +- ✨ Works with Turso [AI & Vector Search](https://docs.turso.tech/features/ai-and-embeddings) |
| 50 | +- 📱 Works with macOS, iPadOS, tvOS, watchOS & iOS |
| 51 | + |
| 52 | +## Install |
| 53 | + |
| 54 | +Add `tursodatabase/libsql-swift` to your SwiftPM dependencies: |
| 55 | + |
| 56 | +```swift |
| 57 | +import PackageDescription |
| 58 | + |
| 59 | +let package = Package( |
| 60 | + // ... |
| 61 | + dependencies: [ |
| 62 | + .package(url: "https://github.com/tursodatabase/libsql-swift", from: "0.1.1"), |
| 63 | + ], |
| 64 | + // ... |
| 65 | +) |
| 66 | +``` |
| 67 | + |
| 68 | +## Quickstart |
| 69 | + |
| 70 | +The example below uses Embedded Replicas and syncs data every 1000ms from Turso. |
| 71 | + |
| 72 | +```swift |
| 73 | +import Libsql |
| 74 | + |
| 75 | +let db = try Libsql.Database( |
| 76 | + path: "./local.db", |
| 77 | + url: "TURSO_DATABASE_URL", |
| 78 | + authToken: "TURSO_AUTH_TOKEN", |
| 79 | + syncInterval: 1000 |
| 80 | +) |
| 81 | + |
| 82 | +let conn = try db.connect() |
| 83 | + |
| 84 | +try conn.execute(" |
| 85 | + CREATE TABLE IF NOT EXISTS users ( |
| 86 | + id INTEGER PRIMARY KEY AUTOINCREMENT, |
| 87 | + name TEXT |
| 88 | + ); |
| 89 | + INSERT INTO users (name) VALUES ('Iku'); |
| 90 | +") |
| 91 | + |
| 92 | +try conn.query("SELECT * FROM users WHERE id = ?", 1) |
| 93 | +``` |
| 94 | + |
| 95 | +## Documentation |
| 96 | + |
| 97 | +Visit our [official documentation](https://docs.turso.tech/sdk/swift). |
| 98 | + |
| 99 | +## Support |
| 100 | + |
| 101 | +Join us [on Discord](https://tur.so/discord-swift) to get help using this SDK. Report security issues [via email](mailto:security@turso.tech). |
| 102 | + |
| 103 | +## Contributors |
| 104 | + |
| 105 | +See the [contributing guide](CONTRIBUTING.md) to learn how to get involved. |
| 106 | + |
| 107 | + |
| 108 | + |
| 109 | +<a href="https://github.com/tursodatabase/libsql-swift/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22"> |
| 110 | + <picture> |
| 111 | + <img src="https://img.shields.io/github/issues-search/tursodatabase/libsql-swift?label=good%20first%20issue&query=label%3A%22good%20first%20issue%22%20&color=0F624B" alt="good first issue" /> |
| 112 | + </picture> |
| 113 | +</a> |
0 commit comments