This package has been modernized for Swift 6.
It provides a Swift wrapper around the libpq client library for connecting to PostgreSQL servers, and a full Perfect-CRUD SQL provider backend for PostgreSQL. Sources/PerfectPostgreSQL/PostgresCRUD.swift implements Perfect-CRUD's SQLGenDelegate, SQLExeDelegate, and DatabaseConfigurationProtocol, so this is no longer a bare, stand-alone libpq connector — it's a CRUD driver that happens to also expose the lower-level PGConnection/PGResult libpq wrapper (Sources/PerfectPostgreSQL/PerfectPostgreSQL.swift, using swift-log for diagnostics rather than print).
Usage status: this driver is real, tested, and consumed today — Perfect-Session's PostgreSQLSessionDriver imports PerfectPostgreSQL directly and is one of Perfect-Session's four supported backend drivers.
The pre-Swift-6 version of this package is preserved on the legacy branch.
Both libpq wrapper types (PGConnection, PGResult) are synchronous/blocking and marked @unchecked Sendable; there is no async/await API in this package.
This package builds with Swift Package Manager. Ensure you have installed and activated a Swift 6.2 (or later) tool chain.
- swift-tools-version: 6.2, built with
swiftLanguageMode(.v6)(strict concurrency) - Platform:
platforms: [.macOS(.v12)]— macOS 12 or later (no other Apple platforms declared) - Linux is buildable via SwiftPM/systemLibrary (the
libpqsystem-library target declares an.apt(["libpq-dev"])provider) but is not asserted in theplatformsarray, so Linux support is implicit, not a guaranteed contract of this manifest.
Declared in Package.swift:
Perfect-CRUD(.package(url:, branch: "main")), productPerfectCRUD.swift-logfrom: 1.5.0, productLogging.- A
.systemLibrarytargetlibpq(viapkgConfig: "libpq") providing the C libpq bindings.
This package requires the libpq client library, available via Homebrew:
brew install libpq
Ensure that you have installed libpq-dev.
sudo apt-get install libpq-dev
Add this project as a dependency in your Package.swift file:
dependencies: [
// No tagged releases exist yet, so pin a branch rather than a version:
.package(url: "https://github.com/PerfectlySoft/Perfect-PostgreSQL.git", branch: "main"),
],
targets: [
.target(
name: "YourTarget",
dependencies: [
.product(name: "PerfectPostgreSQL", package: "Perfect-PostgreSQL"),
]
),
]A test target is included. Run it with:
swift test
Apache 2.0 — see LICENSE.