{"id":17540064,"url":"https://github.com/yockow/swiftpq","last_synced_at":"2026-05-03T06:40:33.634Z","repository":{"id":219867856,"uuid":"750111699","full_name":"YOCKOW/SwiftPQ","owner":"YOCKOW","description":"A simple wrapper of libpq in Swift.","archived":false,"fork":false,"pushed_at":"2026-04-21T02:11:31.000Z","size":884,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-04-21T04:27:50.020Z","etag":null,"topics":["postgresql","swift"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/YOCKOW.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-30T02:10:46.000Z","updated_at":"2026-04-21T02:11:36.000Z","dependencies_parsed_at":"2024-05-09T09:26:52.594Z","dependency_job_id":"b9f35cb9-0955-4610-a8ac-1ea0f704c3df","html_url":"https://github.com/YOCKOW/SwiftPQ","commit_stats":null,"previous_names":["yockow/swiftpq"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/YOCKOW/SwiftPQ","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YOCKOW%2FSwiftPQ","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YOCKOW%2FSwiftPQ/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YOCKOW%2FSwiftPQ/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YOCKOW%2FSwiftPQ/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/YOCKOW","download_url":"https://codeload.github.com/YOCKOW/SwiftPQ/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YOCKOW%2FSwiftPQ/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32560913,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T06:36:36.687Z","status":"ssl_error","status_checked_at":"2026-05-03T06:36:09.306Z","response_time":103,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["postgresql","swift"],"created_at":"2024-10-20T22:08:02.136Z","updated_at":"2026-05-03T06:40:33.607Z","avatar_url":"https://github.com/YOCKOW.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# What is `SwiftPQ`?\n\n`SwiftPQ` is a simple wrapper of [libpq](https://www.postgresql.org/docs/current/libpq.html) that is a C-API to PostgreSQL.\nYou can send query to PostgreSQL server with raw SQL, or in the *Swifty* way[^1].\n\n[^1]: See also [SQLGrammarCorrespondingTypes.md](./SQLGrammarCorrespondingTypes.md)\n\n\u003e [!WARNING]  \n\u003e\n\u003e UNDER DEVELOPMENT. ANY APIs MAY CHANGE IN ANY TIME.\n\n# Requirements\n\n* Swift \u003e= 5.10\n* libpq\n* [libecgp](https://www.postgresql.org/docs/current/app-ecpg.html)\n* [libpgtypes](https://www.postgresql.org/docs/current/ecpg-pgtypes.html)\n\n# Usage\n\n## First of all: Establish the connection.\n\n### By UNIX Socket\n\n```Swift\nimport PQ\n\nlet connection = try Connection(\n  unixSocketDirectoryPath: \"/var/run/postgresql\",\n  database: databaseName,\n  user: databaseUserName,\n  password: databasePassword\n)\n```\n\n### Specifying domain\n\n```Swift\nimport PQ\n\nlet connection = try Connection(\n  host: .localhost,\n  database: databaseName,\n  user: databaseUserName,\n  password: databasePassword\n)\n```\n\n\n## Let's send queries!\n\nYou can see the implementations of commands in \"Sources/PQ/Commands\" directory.\nSome macros are useful to embed SQL tokens into queries. See [Macros.swift](Sources/SQLGrammar/Macros.swift). \n\n### CREATE TABLE\n\n#### Raw SQL\n\n```Swift\nlet result = try await connection.execute(.rawSQL(\"\"\"\nCREATE TABLE products (\n  product_no integer,\n  name text,\n  price numeric\n);\n\"\"\"))\n```\n\n#### SQL with String Interpolation\n\n```Swift\nlet result = try await connection.execute(.rawSQL(\"\"\"\nCREATE TABLE \\(identifier: \"my_products#1\") (\n  product_no integer,\n  name text,\n  price numeric\n);\n\"\"\"))\n```\n\n### Swifty way\n\n```Swift\nlet result = try await connection.execute(\n  .createTable(\n    \"myFavouriteProducts\",\n    definitions: [\n      .column(name: \"product_no\", dataType: .integer),\n      .column(name: \"name\", dataType: .text),\n      .column(name: \"price\", dataType: .numeric),\n    ],\n    ifNotExists: true\n  )\n)\n```\n\n### DROP TABLE\n\n#### Raw SQL\n\n```Swift\nlet result = try await connection.execute(.rawSQL(\"DROP TABLE my_table;\"))\n```\n\n#### SQL with String Interpolation\n\n```Swift\nlet result = try await connection.execute(.rawSQL(\"DROP TABLE \\(identifier: \"my_table#1\");\"))\n```\n\n### Swifty way\n\n```Swift\nlet result = try await connection.execute(.dropTable(\"my_old_table\", ifExists: true))\n```\n\n\n# License\n\nMIT License.  \nSee \"LICENSE.txt\" for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyockow%2Fswiftpq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyockow%2Fswiftpq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyockow%2Fswiftpq/lists"}