Skip to content

Commit a8f2257

Browse files
committed
Document missing features: Windows Auth, reachability check, and advanced connection options
1 parent c5a4837 commit a8f2257

File tree

1 file changed

+43
-11
lines changed

1 file changed

+43
-11
lines changed

README.md

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ This is a Swift rewrite and modernisation of [martinrybak/SQLClient](https://git
1919
- **Typed `SQLRow`** — access columns as `String`, `Int`, `Date`, `UUID`, `Decimal`, and more
2020
- **`SQLDataTable` & `SQLDataSet`** — typed, named tables with JSON serialisation and Markdown rendering
2121
- **Full TLS support**`off`, `request`, `require`, and `strict` (TDS 8.0 / Azure SQL)
22+
- **Windows Authentication** — support for NTLMv2 and Domain-integrated security
2223
- **FreeTDS 1.5** — NTLMv2, read-only AG routing, Kerberos auth, IPv6, cluster failover
2324
- **Affected-row counts**`rowsAffected` from `INSERT` / `UPDATE` / `DELETE`
2425
- **Parameterised queries** — built-in SQL injection protection via `?` placeholders
@@ -46,7 +47,13 @@ This is a Swift rewrite and modernisation of [martinrybak/SQLClient](https://git
4647
> **Note for macOS:** If you encounter compilation errors like `'sybdb.h' file not found`, you need to configure `pkg-config` to correctly link your FreeTDS installation. See [PKG-Config Configuration](#pkg-config-configuration) below.
4748
4849
### Swift Package Manager
49-
...
50+
51+
Add the following to your `Package.swift` dependencies:
52+
53+
```swift
54+
.package(url: "https://github.com/vkuttyp/SQLClient-Swift.git", from: "1.1.3")
55+
```
56+
5057
**macOS (Homebrew):**
5158
```bash
5259
brew install freetds
@@ -134,24 +141,49 @@ try await client.connect(
134141
)
135142
```
136143

137-
For advanced options, use `SQLClientConnectionOptions`:
144+
#### Windows Authentication (Domain Login)
145+
146+
To connect using Windows credentials, provide the `domain` parameter:
138147

139148
```swift
140-
var options = SQLClientConnectionOptions(
141-
server: "myserver.database.windows.net",
142-
username: "myuser",
143-
password: "mypassword",
144-
database: "MyDatabase"
149+
try await client.connect(
150+
server: "myserver",
151+
username: "windows_user",
152+
password: "windows_password",
153+
domain: "YOUR_DOMAIN"
145154
)
155+
```
156+
157+
#### Advanced Connection Options
158+
159+
Use `SQLClientConnectionOptions` for full control over the connection:
160+
161+
```swift
162+
var options = SQLClientConnectionOptions(server: "myserver")
163+
options.username = "myuser"
164+
options.password = "mypassword"
165+
options.database = "MyDatabase"
166+
options.domain = "CORP" // Set domain for Windows Auth
146167
options.port = 1433
147-
options.encryption = .strict // required for Azure SQL / SQL Server 2022
148-
options.loginTimeout = 10 // seconds
149-
options.queryTimeout = 30 // seconds
150-
options.readOnly = true // connect to an Availability Group read replica
168+
options.encryption = .strict // Required for Azure SQL / SQL Server 2022
169+
options.loginTimeout = 10 // Timeout for establishing connection (seconds)
170+
options.queryTimeout = 30 // Timeout for statement execution (seconds)
171+
options.readOnly = true // ApplicationIntent=ReadOnly (for AG replicas)
172+
options.useNTLMv2 = true // Default is true
173+
options.networkAuth = true // Enable network authentication (trusted connection)
174+
options.useUTF16 = true // Use UTF-16 for N-types communication
151175

152176
try await client.connect(options: options)
153177
```
154178

179+
### Pre-flight Reachability Check
180+
181+
You can optionally check if the SQL Server port is reachable before attempting a full login. This is useful for failing fast with a clear error:
182+
183+
```swift
184+
try await client.checkReachability(server: "myserver", port: 1433)
185+
```
186+
155187
### Querying — `SQLRow`
156188

157189
`query()` returns `[SQLRow]` from the first result set. Each `SQLRow` provides ordered, typed column access:

0 commit comments

Comments
 (0)