All Projects → vapor-community → Postgresql Provider

vapor-community / Postgresql Provider

Licence: mit
PostgreSQL Provider for the Vapor web framework.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Postgresql Provider

Endb
Key-value storage for multiple databases. Supports MongoDB, MySQL, Postgres, Redis, and SQLite.
Stars: ✭ 208 (+192.96%)
Mutual labels:  database, postgresql, cache
Fluent Sqlite Driver
Fluent driver for SQLite
Stars: ✭ 51 (-28.17%)
Mutual labels:  database, vapor
Postgresclientkit
A PostgreSQL client library for Swift. Does not require libpq.
Stars: ✭ 49 (-30.99%)
Mutual labels:  database, postgresql
Fluent
Vapor ORM (queries, models, and relations) for NoSQL and SQL databases
Stars: ✭ 1,071 (+1408.45%)
Mutual labels:  database, vapor
Goqu
SQL builder and query library for golang
Stars: ✭ 984 (+1285.92%)
Mutual labels:  database, postgresql
Niklick
Rails Versioned API solution template for hipsters! (Ruby, Ruby on Rails, REST API, GraphQL, Docker, RSpec, Devise, Postgress DB)
Stars: ✭ 39 (-45.07%)
Mutual labels:  database, postgresql
Dbbench
🏋️ dbbench is a simple database benchmarking tool which supports several databases and own scripts
Stars: ✭ 52 (-26.76%)
Mutual labels:  database, postgresql
Go Kallax
Kallax is a PostgreSQL typesafe ORM for the Go language.
Stars: ✭ 853 (+1101.41%)
Mutual labels:  database, postgresql
Pgtune
Pgtune - tuning PostgreSQL config by your hardware
Stars: ✭ 1,078 (+1418.31%)
Mutual labels:  database, postgresql
Squid
🦑 Provides SQL tagged template strings and schema definition functions.
Stars: ✭ 57 (-19.72%)
Mutual labels:  database, postgresql
Scalikejdbc
A tidy SQL-based DB access library for Scala developers. This library naturally wraps JDBC APIs and provides you easy-to-use APIs.
Stars: ✭ 1,139 (+1504.23%)
Mutual labels:  database, postgresql
Laravel Pg Extensions
Laravel extensions for Postgres
Stars: ✭ 33 (-53.52%)
Mutual labels:  database, postgresql
Laravel Couchbase
Couchbase providers for Laravel
Stars: ✭ 31 (-56.34%)
Mutual labels:  database, cache
Perfect Postgresql
A stand-alone Swift wrapper around the libpq client library, enabling access to PostgreSQL servers.
Stars: ✭ 48 (-32.39%)
Mutual labels:  database, postgresql
Awesome Postgres
A curated list of awesome PostgreSQL software, libraries, tools and resources, inspired by awesome-mysql
Stars: ✭ 7,468 (+10418.31%)
Mutual labels:  database, postgresql
Hunt Entity
An object-relational mapping (ORM) framework for D language (Similar to JPA / Doctrine), support PostgreSQL and MySQL.
Stars: ✭ 51 (-28.17%)
Mutual labels:  database, postgresql
Dbmigrations
A library for the creation, management, and installation of schema updates for relational databases.
Stars: ✭ 67 (-5.63%)
Mutual labels:  database, postgresql
Docker Postgres
A docker container running PostgreSQL
Stars: ✭ 22 (-69.01%)
Mutual labels:  database, postgresql
Node Pg Migrate
Node.js database migration management for Postgresql
Stars: ✭ 838 (+1080.28%)
Mutual labels:  database, postgresql
Ansible Role Memcached
Ansible Role - Memcached
Stars: ✭ 54 (-23.94%)
Mutual labels:  database, cache

Swift Linux Build Status macOS Build Status codecov GitHub license

PostgreSQL Provider for Vapor

Adds PostgreSQL support to the Vapor web framework.

Prerequisites

The PostgreSQL C driver must be installed in order to use this package.
Follow the README of the cpostgresql repo to get started.

Setup

Note that the process is different for Swift 3 and 4.

  1. Add the dependency to project

    • Swift 3: add to Package.swift package dependencies
      .Package(url: "https://github.com/vapor-community/postgresql-provider.git", majorVersion: 2, minor: 1)
      
    • Swift 4: add to Package.swift package and target dependencies
      .package(url: "https://github.com/vapor-community/postgresql-provider.git", .upToNextMajor(from: "2.1.0"))
      // ...
      .target(name: "App", dependencies: ["Vapor", "FluentProvider", "PostgreSQLProvider"], ...)
      
  2. Fetch dependencies and regenerate the Xcode project

    vapor update
    

Usage

import Vapor
import PostgreSQLProvider

let config = try Config()
try config.addProvider(PostgreSQLProvider.Provider.self)

let drop = try Droplet(config)

Configure Fluent

Once the provider is added to your Droplet, you can configure Fluent to use the PostgreSQL driver.

Config/fluent.json

  "driver": "postgresql"

Configure PostgreSQL

Basic

Here is an example of a simple PostgreSQL configuration file.

Config/secrets/postgresql.json

{
    "hostname": "127.0.0.1",
    "user": "postgres",
    "password": "hello",
    "database": "test",
    "port": 5432
}

Alternatively, you can set a url with the configuration parameters.

Config/secrets/postgresql.json

{
    "url": "psql://user:[email protected]:5432/database"
}

Read Replicas

Read replicas can be supplied by passing a single master hostname and an array of readReplicas hostnames.

Config/secrets/postgresql.json

{
    "master": "master.postgresql.foo.com",
    "readReplicas": ["read01.postgresql.foo.com", "read02.postgresql.foo.com"],
    "user": "postgres",
    "password": "hello",
    "database": "test",
    "port": 5432
}

Driver

You can get access to the PostgreSQL Driver on the droplet.

import Vapor
import PostgreSQLProvider

let postgresqlDriver = try drop.postgresql()
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].