{"id":13396533,"url":"https://github.com/codewinsdotcom/PostgresClientKit","last_synced_at":"2025-03-13T23:31:27.050Z","repository":{"id":40725053,"uuid":"174378326","full_name":"codewinsdotcom/PostgresClientKit","owner":"codewinsdotcom","description":"A PostgreSQL client library for Swift. Does not require libpq.","archived":false,"fork":false,"pushed_at":"2023-02-12T16:32:53.000Z","size":678,"stargazers_count":133,"open_issues_count":2,"forks_count":21,"subscribers_count":13,"default_branch":"master","last_synced_at":"2024-09-30T21:01:45.240Z","etag":null,"topics":["database","postgres","postgresql","server-side-swift","swift"],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codewinsdotcom.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-03-07T16:10:45.000Z","updated_at":"2024-09-27T11:00:30.000Z","dependencies_parsed_at":"2024-01-06T10:27:44.458Z","dependency_job_id":null,"html_url":"https://github.com/codewinsdotcom/PostgresClientKit","commit_stats":{"total_commits":160,"total_committers":2,"mean_commits":80.0,"dds":0.006249999999999978,"last_synced_commit":"c2768c8ebe708b1c5937431972c7882b33f4ea49"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codewinsdotcom%2FPostgresClientKit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codewinsdotcom%2FPostgresClientKit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codewinsdotcom%2FPostgresClientKit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codewinsdotcom%2FPostgresClientKit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codewinsdotcom","download_url":"https://codeload.github.com/codewinsdotcom/PostgresClientKit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243500051,"owners_count":20300737,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","postgres","postgresql","server-side-swift","swift"],"created_at":"2024-07-30T18:00:56.174Z","updated_at":"2025-03-13T23:31:26.613Z","avatar_url":"https://github.com/codewinsdotcom.png","language":"Swift","funding_links":[],"categories":["Databases","Packages","Swift","Data and Storage"],"sub_categories":["Database"],"readme":"# PostgresClientKit\n\n\u003cp\u003e\n\n  \u003ca href=\"https://codewinsdotcom.github.io/PostgresClientKit/Docs/API/index.html\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/api-docs-blue.svg\"\u003e\n  \u003c/a\u003e\n  \n  \u003cimg src=\"https://img.shields.io/badge/swift-5-green.svg\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/os-linux-green.svg\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/os-macOS-green.svg\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/os-iOS-green.svg\"\u003e  \n  \n  \u003cimg src=\"https://img.shields.io/github/release/codewinsdotcom/PostgresClientKit.svg\"\u003e\n  \u003cimg src=\"https://img.shields.io/github/license/codewinsdotcom/PostgresClientKit.svg\"\u003e\n  \n\u003c/p\u003e\n\nPostgresClientKit provides a friendly Swift API for operating against a PostgreSQL database.\n\n## Features\n\n- **Doesn't require libpq.**  PostgresClientKit implements the Postgres network protocol in Swift, so it does not require `libpq`.\n\n- **Developer-friendly API using modern Swift.**  For example, errors are represented by instances of `enum PostgresError: Error` and are raised by a `throw` or by returning a [`Result\u003cSuccess, Error\u003e`](https://github.com/apple/swift-evolution/blob/master/proposals/0235-add-result.md).\n\n- **Safe conversion between Postgres and Swift types.** Type conversion is explicit and robust.  Conversion errors are signaled, not masked.  PostgresClientKit provides additional Swift types for dates and times to address the impedance mismatch between Postgres types and Foundation `Date`.\n\n- **Memory efficient.** The rows in a result are exposed through an iterator, not an array.  Rows are lazily retrieved from the Postgres server.\n\n- **SSL/TLS support.** Encrypts the connection between PostgresClientKit and the Postgres server.\n\n- **Well-engineered**.  Complete API documentation, an extensive test suite, actively supported.\n\nSounds good?  Let's look at an example.\n\n## Example\n\nThis is a basic, but complete, example of how to connect to Postgres, perform a SQL `SELECT` command, and process the resulting rows.  It uses the `weather` table in the [Postgres tutorial](https://www.postgresql.org/docs/11/tutorial-table.html).\n\n```swift\nimport PostgresClientKit\n\ndo {\n    var configuration = PostgresClientKit.ConnectionConfiguration()\n    configuration.host = \"127.0.0.1\"\n    configuration.database = \"example\"\n    configuration.user = \"bob\"\n    configuration.credential = .scramSHA256(password: \"welcome1\")\n\n    let connection = try PostgresClientKit.Connection(configuration: configuration)\n    defer { connection.close() }\n\n    let text = \"SELECT city, temp_lo, temp_hi, prcp, date FROM weather WHERE city = $1;\"\n    let statement = try connection.prepareStatement(text: text)\n    defer { statement.close() }\n\n    let cursor = try statement.execute(parameterValues: [ \"San Francisco\" ])\n    defer { cursor.close() }\n\n    for row in cursor {\n        let columns = try row.get().columns\n        let city = try columns[0].string()\n        let tempLo = try columns[1].int()\n        let tempHi = try columns[2].int()\n        let prcp = try columns[3].optionalDouble()\n        let date = try columns[4].date()\n    \n        print(\"\"\"\n            \\(city) on \\(date): low: \\(tempLo), high: \\(tempHi), \\\n            precipitation: \\(String(describing: prcp))\n            \"\"\")\n    }\n} catch {\n    print(error) // better error handling goes here\n}\n```\n\nOutput:\n\n```\nSan Francisco on 1994-11-27: low: 46, high: 50, precipitation: Optional(0.25)\nSan Francisco on 1994-11-29: low: 43, high: 57, precipitation: Optional(0.0)\n```\n\n## Prerequisites\n\n- **Swift 5 or later**  (PostgresClientKit uses Swift 5 language features)\n- **`libssl-dev`** (only required on Linux)\n\nPostgresClientKit is compatible with Linux, macOS, and iOS.  It has been tested on:\n\n- Ubuntu 18.04 LTS, 20.04 LTS\n- macOS 10.14, 10.15, 11, 12\n- iOS 12, 13, 14, 15\n- Postgres 10, 11, 12, 13, 14\n\n## Building\n\n```\ncd \u003cpath-to-clone\u003e\nswift package clean\nswift build\n```\n\n## Testing\n\n[Set up a Postgres database for testing](https://github.com/codewinsdotcom/PostgresClientKit/blob/master/Docs/setting_up_a_postgres_database_for_testing.md).  This is a one-time process.\n\nThen:\n\n```\ncd \u003cpath-to-clone\u003e\nswift package clean\nswift build\nswift test\n```\n\n## Using\n\n### From an Xcode project (as a package dependency)\n\nIn Xcode:\n\n- Select File \u003e Add Packages...\n\n- Enter the package URL: `https://github.com/codewinsdotcom/PostgresClientKit`\n\n- Set the package version requirements (see [Decide on Package Requirements](https://developer.apple.com/documentation/xcode/adding-package-dependencies-to-your-app)).  For example, choose `Up To Next Major Version` and `1.0.0` to select the latest 1.x.x release of PostgresClientKit.\n\n- Click Add Package.\n\nImport to your source code file:\n\n```swift\nimport PostgresClientKit\n```\n\n### From a standalone Swift package (`Package.swift`)\n\nIn your `Package.swift` file:\n\n- Add PostgresClientKit to the `dependencies`.  For example:\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/codewinsdotcom/PostgresClientKit\", from: \"1.0.0\"),\n],\n```\n\n- Reference the `PostgresClientKit` product in the `targets`.  For example:\n\n```swift\ntargets: [\n    .target(\n        name: \"MyProject\",\n        dependencies: [\"PostgresClientKit\"]),\n]\n```\n\nImport to your source code file:\n\n```swift\nimport PostgresClientKit\n```\n\n### Using CocoaPods\n\nAdd `PostgresClientKit` to your `Podfile`.  For example:\n\n```\ntarget 'MyApp' do\n  pod 'PostgresClientKit', '~\u003e 1.0'\nend\n```\n\nThen run `pod install`.\n\nImport to your source code file:\n\n```swift\nimport PostgresClientKit\n```\n\n## Documentation\n\n- [API](https://codewinsdotcom.github.io/PostgresClientKit/Docs/API/index.html)\n- [Troubleshooting](https://github.com/codewinsdotcom/PostgresClientKit/blob/master/Docs/troubleshooting.md)\n- [FAQ](https://github.com/codewinsdotcom/PostgresClientKit/blob/master/Docs/faq.md)\n\n## Additional examples\n\n- [PostgresClientKit-CommandLine-Example](https://github.com/pitfield/PostgresClientKit-CommandLine-Example): an example command-line application\n\n- [PostgresClientKit-iOS-Example](https://github.com/pitfield/PostgresClientKit-iOS-Example): an example iOS app\n\n## Contributing\n\nThank you for your interest in contributing to PostgresClientKit.\n\nThis project has a code of conduct.  See [CODE_OF_CONDUCT.md](https://github.com/codewinsdotcom/PostgresClientKit/blob/master/CODE_OF_CONDUCT.md) for details.\n\nPlease use [issues](https://github.com/codewinsdotcom/PostgresClientKit/issues) to:\n\n- ask questions\n- report problems (bugs)\n- request enhancements\n\nPull requests against the `develop` branch are welcomed.  For a non-trivial contribution (for example, more than correcting spelling, typos, or whitespace) please first discuss the proposed change by opening an issue.\n    \n## License\n\nPostgresClientKit is licensed under the Apache 2.0 license.  See [LICENSE](https://github.com/codewinsdotcom/PostgresClientKit/blob/master/LICENSE) for details.\n\n## Versioning\n\nPostgresClientKit uses [Semantic Versioning 2.0.0](https://semver.org).  For the versions available, see the [tags on this repository](https://github.com/codewinsdotcom/PostgresClientKit/releases).\n\n## Built with\n\n- [Kitura BlueSocket](https://github.com/Kitura/BlueSocket) - socket library\n- [Kitura BlueSSLService](https://github.com/Kitura/BlueSSLService) - SSL/TLS support\n- [Jazzy](https://github.com/realm/jazzy) - generation of API documentation pages\n\n## Authors\n\n- David Pitfield [(@pitfield)](https://github.com/pitfield)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodewinsdotcom%2FPostgresClientKit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodewinsdotcom%2FPostgresClientKit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodewinsdotcom%2FPostgresClientKit/lists"}