Skip to content

Commit f7bdfeb

Browse files
committed
Driver/Swift: Add dedicated page
1 parent 7d4beb4 commit f7bdfeb

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed

docs/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@
8686
r"https://aiven.io/",
8787
# HTTPSConnectionPool(host='qz.surister.dev', port=443): Read timed out. (read timeout=15)
8888
r"https://qz.surister.dev/",
89+
# 403 Client Error: Forbidden
90+
r"https://swiftpackageindex.com/",
8991
]
9092

9193
linkcheck_anchors_ignore_for_url += [

docs/connect/index.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,18 @@ CrateDB drivers and adapters for supported programming languages, frameworks, an
113113

114114
::::
115115

116+
::::{grid-item-card} Swift
117+
:link: connect-swift
118+
:link-type: ref
119+
:link-alt: Connect to CrateDB using Swift
120+
:padding: 3
121+
:text-align: center
122+
:class-card: sd-pt-3
123+
:class-body: sd-fs-1
124+
:class-title: sd-fs-6
125+
{fab}`swift`
126+
::::
127+
116128
:::::
117129

118130

@@ -187,6 +199,7 @@ javascript
187199
php
188200
python
189201
ruby
202+
swift
190203
natural
191204
All drivers <drivers>
192205
```

docs/connect/swift.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
(connect-swift)=
2+
3+
# Swift
4+
5+
:::{include} /_include/links.md
6+
:::
7+
8+
:::{div} sd-text-muted
9+
Connect to CrateDB from Swift applications.
10+
:::
11+
12+
:::{rubric} About
13+
:::
14+
15+
[postgres-kit] is a non-blocking, event-driven Swift client for PostgreSQL.
16+
17+
:::{rubric} Synopsis
18+
:::
19+
20+
`Package.swift`
21+
```text
22+
dependencies: [
23+
.package(url: "https://github.com/vapor/postgres-kit.git", from: "2.0.0")
24+
]
25+
```
26+
`Sources/main.swift`
27+
```swift
28+
import PostgresKit
29+
30+
let configuration = SQLPostgresConfiguration(url: "postgres://crate:crate@localhost:5432")
31+
let source = PostgresConnectionSource(configuration: configuration)
32+
let pool = EventLoopGroupConnectionPool(
33+
source: source,
34+
maxConnectionsPerEventLoop: 2,
35+
on: MultiThreadedEventLoopGroup.singleton
36+
)
37+
defer { pool.shutdown() }
38+
39+
let db = pool.database(logger: .init(label: "test")).sql()
40+
let rows = try db.raw("SELECT * FROM sys.summits ORDER BY height DESC LIMIT 10;").all().wait()
41+
print(rows)
42+
```
43+
44+
45+
[postgres-kit]: https://swiftpackageindex.com/vapor/postgres-kit

0 commit comments

Comments
 (0)