Skip to content

Latest commit

 

History

135 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Perfect - PostgreSQL Connector

Swift 6.2 Platforms macOS 12+ License Apache

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.

Requirements

  • 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 libpq system-library target declares an .apt(["libpq-dev"]) provider) but is not asserted in the platforms array, so Linux support is implicit, not a guaranteed contract of this manifest.

Dependencies

Declared in Package.swift:

  • Perfect-CRUD (.package(url:, branch: "main")), product PerfectCRUD.
  • swift-log from: 1.5.0, product Logging.
  • A .systemLibrary target libpq (via pkgConfig: "libpq") providing the C libpq bindings.

macOS Build Notes

This package requires the libpq client library, available via Homebrew:

brew install libpq

Linux Build Notes

Ensure that you have installed libpq-dev.

sudo apt-get install libpq-dev

Building

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"),
        ]
    ),
]

Testing

A test target is included. Run it with:

swift test

License

Apache 2.0 — see LICENSE.

About

A stand-alone Swift wrapper around the libpq client library, enabling access to PostgreSQL servers.

Topics

Resources

Stars

53 stars

Watchers

5 watching

Forks

Releases

Packages

Used by

Contributors

Languages