Skip to main content

PostgreSQL testing helpers

Project description

Postgresql testing

Simple Postgres helpers for testing with Python - no docker, brew, apt, etc - uses postgresql-binaries.

pip install postgresql-testing 'postgresql-binaries==18.*'

Then to use, eg:

import postgresql_testing

@pytest.fixture(scope="session")
def db() -> Iterator[str]:
    config = postgresql_testing.DatabaseConfig.default("testing-db")
    postgresql_testing.initdb(config.directory, on_existing="use")
    with postgresql_testing.serve(config):
        postgresql_testing.ensure_user(config)
        postgresql_testing.create_database(config, on_existing="replace")
        yield config.dsn

There are various useful flags and things - the source code is short enough to just dive in.


There are a couple of helpers for creating/using template dbs and tar files. I have some vague long term plan for some kind of "Docker layers for migrated databases" with clever caching, but I'm not quite sure what it looks like yet.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

postgresql_testing-0.0.1.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

postgresql_testing-0.0.1-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file postgresql_testing-0.0.1.tar.gz.

File metadata

  • Download URL: postgresql_testing-0.0.1.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for postgresql_testing-0.0.1.tar.gz
Algorithm Hash digest
SHA256 5d8bb02461d40cc22aebfdc7e4fa4426695ba973f6d38c9b5a820ff56e2680aa
MD5 c2fdb649d488ff2aedaf0955b81e5d22
BLAKE2b-256 7d1b8603041c1a4bb6d2cc14b2217900c6ab10d95d6831c0870d90c7b599d056

See more details on using hashes here.

File details

Details for the file postgresql_testing-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: postgresql_testing-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for postgresql_testing-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 63f0020c48825ee98833c08a2d153cbec91d1862f92ca4bd434949c5805c3f3e
MD5 d707ea5312268427b9e28a1b05d17a2a
BLAKE2b-256 79cb98f648ee4e760cfa769219bc96f1ffa2de4ba6464cf4edb11647a5674193

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page