@@ -65,6 +65,8 @@ A unified Swift package for connecting to **Microsoft SQL Server**, **PostgreSQL
6565| ` SQLDataTable ` / ` SQLDataSet ` | ✅ | ✅ | ✅ | ✅ |
6666| ` Codable ` row decoding | ✅ | ✅ | ✅ | ✅ |
6767| Markdown table output | ✅ | ✅ | ✅ | ✅ |
68+ | JSON output (` toJson(pretty:) ` ) | ✅ | ✅ | ✅ | ✅ |
69+ | Codable row mapping (` decode<T: Decodable> ` ) | ✅ | ✅ | ✅ | ✅ |
6870| Logical SQL dump | ✅ | ✅ | ✅ | ✅ |
6971| Native binary backup | — | — | — | ✅ |
7072| In-memory database | — | — | — | ✅ |
@@ -88,11 +90,11 @@ Then add the product(s) you need to your target:
8890.target (
8991 name : " MyApp" ,
9092 dependencies : [
91- .product (name : " CosmoMSSQL" , package : " cosmo-sql-client " ), // SQL Server
92- .product (name : " CosmoPostgres" , package : " cosmo-sql-client " ), // PostgreSQL
93- .product (name : " CosmoMySQL" , package : " cosmo-sql-client " ), // MySQL / MariaDB
94- .product (name : " CosmoSQLite" , package : " cosmo-sql-client " ), // SQLite
95- .product (name : " CosmoSQLCore" , package : " cosmo-sql-client " ), // Shared types only
93+ .product (name : " CosmoMSSQL" , package : " CosmoSQLClient " ), // SQL Server
94+ .product (name : " CosmoPostgres" , package : " CosmoSQLClient " ), // PostgreSQL
95+ .product (name : " CosmoMySQL" , package : " CosmoSQLClient " ), // MySQL / MariaDB
96+ .product (name : " CosmoSQLite" , package : " CosmoSQLClient " ), // SQLite
97+ .product (name : " CosmoSQLCore" , package : " CosmoSQLClient " ), // Shared types only
9698 ]
9799),
98100```
@@ -498,6 +500,51 @@ let orderItems = dataSet["result1"]
498500
499501---
500502
503+ ## SQLDataTable & Output Formats
504+
505+ Convert query results to a rich in - memory table with multiple output formats:
506+
507+ ```swift
508+ let rows = try await conn.query (" SELECT * FROM Accounts" , [])
509+ let table = rows.asDataTable (name : " Accounts" )
510+
511+ print (" Rows: \( table.rowCount ) , Columns: \( table.columnCount ) " )
512+
513+ // Markdown table
514+ print (table.toMarkdown ())
515+
516+ // JSON array (pretty-printed by default)
517+ print (table.toJson ())
518+
519+ // Compact JSON
520+ print (table.toJson (pretty : false ))
521+
522+ // Codable mapping — like Swift's Decodable
523+ let accounts = try table.decode (as : Account.self )
524+ ```
525+
526+ ```swift
527+ struct Account : Decodable {
528+ let accountNo: String
529+ let accountName: String
530+ let isMain: Bool
531+ }
532+ ```
533+
534+ The `toJson ()` output uses native types:
535+ ```json
536+ [
537+ {
538+ " AccountNo" : " 1" ,
539+ " AccountName" : " Assets" ,
540+ " IsMain" : true ,
541+ " AccountTypeID" : 1
542+ }
543+ ]
544+ ```
545+
546+ ---
547+
501548## Transactions
502549
503550All four drivers support `BEGIN` / `COMMIT` / `ROLLBACK` with a convenient closure- based wrapper:
@@ -1037,7 +1084,8 @@ swift test
10371084- [SwiftNIO](https:// github.com/apple/swift-nio) — The async networking engine powering CosmoSQLClient-Swift
10381085- [swift-nio-ssl](https:// github.com/apple/swift-nio-ssl) — TLS support
10391086- [postgres-nio](https:// github.com/vapor/postgres-nio) — Vapor's PostgreSQL driver (separate project)
1040- - [myCosmoSQLClient-Swift](https:// github.com/vapor/myCosmoSQLClient-Swift) — Vapor's MySQL driver (separate project)
1087+ - [mysql-nio](https:// github.com/vapor/mysql-nio) — Vapor's MySQL driver (separate project)
1088+ - [CosmoSQLClient-Dotnet](https:// github.com/vkuttyp/CosmoSQLClient-Dotnet) — The .NET port of this package (MSSQL, PostgreSQL, MySQL, SQLite)
10411089
10421090---
10431091
0 commit comments