All Projects → opentable → Otj Pg Embedded

opentable / Otj Pg Embedded

Licence: apache-2.0
Java embedded PostgreSQL component for testing

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Otj Pg Embedded

Pg chameleon
MySQL to PostgreSQL replica system
Stars: ✭ 274 (-50.98%)
Mutual labels:  database, postgres
Crecto
Database wrapper and ORM for Crystal, inspired by Ecto
Stars: ✭ 325 (-41.86%)
Mutual labels:  database, postgres
Dbq
Zero boilerplate database operations for Go
Stars: ✭ 273 (-51.16%)
Mutual labels:  database, postgres
Wetland
A Node.js ORM, mapping-based. Works with MySQL, PostgreSQL, SQLite and more.
Stars: ✭ 261 (-53.31%)
Mutual labels:  database, postgres
Sqlboiler
Generate a Go ORM tailored to your database schema.
Stars: ✭ 4,497 (+704.47%)
Mutual labels:  database, postgres
Postgui
A React web application to query and share any PostgreSQL database.
Stars: ✭ 260 (-53.49%)
Mutual labels:  database, postgres
Architect
A set of tools which enhances ORMs written in Python with more features
Stars: ✭ 320 (-42.75%)
Mutual labels:  database, postgres
Rpostgres
A DBI-compliant interface to PostgreSQL
Stars: ✭ 245 (-56.17%)
Mutual labels:  database, postgres
Jet
Type safe SQL builder with code generation and automatic query result data mapping
Stars: ✭ 373 (-33.27%)
Mutual labels:  database, postgres
Tgbot
Modular telegram group management bot
Stars: ✭ 334 (-40.25%)
Mutual labels:  database, postgres
Pg insights
A collection of convenient SQL for monitoring Postgres database health.
Stars: ✭ 253 (-54.74%)
Mutual labels:  database, postgres
Zero downtime migrations
Zero downtime migrations with ActiveRecord 3+ and PostgreSQL
Stars: ✭ 513 (-8.23%)
Mutual labels:  database, postgres
Flask Boilerplate
Simple flask boilerplate with Postgres, Docker, and Heroku/Zeit now
Stars: ✭ 251 (-55.1%)
Mutual labels:  database, postgres
Questdb
An open source SQL database designed to process time series data, faster
Stars: ✭ 7,544 (+1249.55%)
Mutual labels:  database, postgres
Scenic
Scenic is maintained by Derek Prior, Caleb Hearth, and you, our contributors.
Stars: ✭ 2,856 (+410.91%)
Mutual labels:  database, postgres
Ansible Role Postgresql
Ansible Role - PostgreSQL
Stars: ✭ 310 (-44.54%)
Mutual labels:  database, postgres
Massive Js
A data mapper for Node.js and PostgreSQL.
Stars: ✭ 2,521 (+350.98%)
Mutual labels:  database, postgres
Prest
PostgreSQL ➕ REST, low-code, simplify and accelerate development, ⚡ instant, realtime, high-performance on any Postgres application, existing or new
Stars: ✭ 3,023 (+440.79%)
Mutual labels:  database, postgres
Rdbc
Rust DataBase Connectivity (RDBC) :: Common Rust API for database drivers
Stars: ✭ 328 (-41.32%)
Mutual labels:  database, postgres
Gnorm
A database-first code generator for any language
Stars: ✭ 415 (-25.76%)
Mutual labels:  database, postgres

OpenTable Embedded PostgreSQL Component

Allows embedding PostgreSQL into Java application code with no external dependencies. Excellent for allowing you to unit test with a "real" Postgres without requiring end users to install and set up a database cluster.

Build Status

Basic Usage

In your JUnit test just add:

@Rule
public SingleInstancePostgresRule pg = EmbeddedPostgresRules.singleInstance();

This simply has JUnit manage an instance of EmbeddedPostgres (start, stop). You can then use this to get a DataSource with: pg.getEmbeddedPostgres().getPostgresDatabase();

Additionally you may use the EmbeddedPostgres class directly by manually starting and stopping the instance; see EmbeddedPostgresTest for an example.

Default username/password is: postgres/postgres and the default database is 'postgres'

Migrators (Flyway or Liquibase)

You can easily integrate Flyway or Liquibase database schema migration:

Flyway
@Rule 
public PreparedDbRule db =
    EmbeddedPostgresRules.preparedDatabase(
        FlywayPreparer.forClasspathLocation("db/my-db-schema"));
Liquibase
@Rule
public PreparedDbRule db = 
    EmbeddedPostgresRules.preparedDatabase(
            LiquibasePreparer.forClasspathLocation("liqui/master.xml"));

This will create an independent database for every test with the given schema loaded from the classpath. Database templates are used so the time cost is relatively small, given the superior isolation truly independent databases gives you.

Postgres version

The JAR file contains bundled version of Postgres. You can pass different Postgres version by implementing PgBinaryResolver.

Example:

class ClasspathBinaryResolver implements PgBinaryResolver {
    public InputStream getPgBinary(String system, String machineHardware) throws IOException {
        ClassPathResource resource = new ClassPathResource(format("postgresql-%s-%s.txz", system, machineHardware));
        return resource.getInputStream();
    }
}

EmbeddedPostgreSQL
            .builder()
            .setPgBinaryResolver(new ClasspathBinaryResolver())
            .start();

Windows

If you experience difficulty running otj-pg-embedded tests on Windows, make sure you've installed the appropriate MFC redistributables.


Copyright (C) 2017 OpenTable, Inc

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].