{"id":20757228,"url":"https://github.com/vapor-community/postgresql-provider","last_synced_at":"2025-04-29T08:55:57.652Z","repository":{"id":66562607,"uuid":"63613251","full_name":"vapor-community/postgresql-provider","owner":"vapor-community","description":"PostgreSQL Provider for the Vapor web framework.","archived":false,"fork":false,"pushed_at":"2018-01-16T17:27:39.000Z","size":41,"stargazers_count":69,"open_issues_count":1,"forks_count":19,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-04-29T08:55:44.008Z","etag":null,"topics":["cache","database","postgresql","swift","vapor","vapor-provider"],"latest_commit_sha":null,"homepage":null,"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/vapor-community.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2016-07-18T15:09:10.000Z","updated_at":"2024-11-30T23:38:09.000Z","dependencies_parsed_at":"2023-02-26T08:00:32.754Z","dependency_job_id":null,"html_url":"https://github.com/vapor-community/postgresql-provider","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vapor-community%2Fpostgresql-provider","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vapor-community%2Fpostgresql-provider/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vapor-community%2Fpostgresql-provider/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vapor-community%2Fpostgresql-provider/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vapor-community","download_url":"https://codeload.github.com/vapor-community/postgresql-provider/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251470282,"owners_count":21594524,"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":["cache","database","postgresql","swift","vapor","vapor-provider"],"created_at":"2024-11-17T09:41:00.626Z","updated_at":"2025-04-29T08:55:57.645Z","avatar_url":"https://github.com/vapor-community.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Swift](https://img.shields.io/badge/swift-3.1_--_4.0-brightgreen.svg)](https://swift.org)\n[![Linux Build Status](https://img.shields.io/circleci/project/github/vapor-community/postgresql-provider.svg?label=Linux)](https://circleci.com/gh/vapor-community/postgresql-provider)\n[![macOS Build Status](https://img.shields.io/travis/vapor-community/postgresql-provider.svg?label=macOS)](https://travis-ci.org/vapor-community/postgresql-provider)\n[![codecov](https://codecov.io/gh/vapor-community/postgresql-provider/branch/master/graph/badge.svg)](https://codecov.io/gh/vapor-community/postgresql-provider)\n[![GitHub license](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE)\n\n# PostgreSQL Provider for Vapor\nAdds PostgreSQL support to the Vapor web framework.\n\n## Prerequisites\n\nThe PostgreSQL C driver must be installed in order to use this package.  \nFollow the [README of the cpostgresql repo](https://github.com/vapor-community/cpostgresql/blob/master/README.md) to get started.\n\n## Setup\nNote that the process is different for Swift 3 and 4.\n\n1. Add the dependency to project\n    - Swift 3: add to Package.swift package dependencies\n        ```swift\n        .Package(url: \"https://github.com/vapor-community/postgresql-provider.git\", majorVersion: 2, minor: 1)\n        ```\n    - Swift 4: add to Package.swift package _and target_ dependencies\n        ```swift\n        .package(url: \"https://github.com/vapor-community/postgresql-provider.git\", .upToNextMajor(from: \"2.1.0\"))\n        // ...\n        .target(name: \"App\", dependencies: [\"Vapor\", \"FluentProvider\", \"PostgreSQLProvider\"], ...)\n        ```\n\n2. Fetch dependencies and regenerate the Xcode project\n    ```bash\n    vapor update\n    ```\n\n## Usage\n\n```swift\nimport Vapor\nimport PostgreSQLProvider\n\nlet config = try Config()\ntry config.addProvider(PostgreSQLProvider.Provider.self)\n\nlet drop = try Droplet(config)\n```\n\n## Configure Fluent\nOnce the provider is added to your Droplet, you can configure Fluent to use the PostgreSQL driver.\n\n `Config/fluent.json`\n \n```json\n  \"driver\": \"postgresql\"\n```\n\n## Configure PostgreSQL\n### Basic\nHere is an example of a simple PostgreSQL configuration file.\n\n `Config/secrets/postgresql.json`\n \n```json\n{\n    \"hostname\": \"127.0.0.1\",\n    \"user\": \"postgres\",\n    \"password\": \"hello\",\n    \"database\": \"test\",\n    \"port\": 5432\n}\n```\n\nAlternatively, you can set a url with the configuration parameters.\n\n `Config/secrets/postgresql.json`\n \n```json\n{\n    \"url\": \"psql://user:pass@hostname:5432/database\"\n}\n```\n\n### Read Replicas\nRead replicas can be supplied by passing a single `master` hostname and an array of `readReplicas` hostnames.\n\n `Config/secrets/postgresql.json`\n \n```json\n{\n    \"master\": \"master.postgresql.foo.com\",\n    \"readReplicas\": [\"read01.postgresql.foo.com\", \"read02.postgresql.foo.com\"],\n    \"user\": \"postgres\",\n    \"password\": \"hello\",\n    \"database\": \"test\",\n    \"port\": 5432\n}\n```\n\n### Driver\nYou can get access to the PostgreSQL Driver on the droplet.\n\n```swift\nimport Vapor\nimport PostgreSQLProvider\n\nlet postgresqlDriver = try drop.postgresql()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvapor-community%2Fpostgresql-provider","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvapor-community%2Fpostgresql-provider","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvapor-community%2Fpostgresql-provider/lists"}