Skip to main content

Self-contained postgres server for your python applications

Project description

pgserver: pip installable self-contained postgres server

pip install pgserver

pgserver lets you create and manage a Postgres within your Python app, with server binaries included. Wheels are built for multiple platforms.

Example use cases:

  • Building a Postgres-backed yet still self-contained Python app, much like you would with sqlite.
  • Developing and testing apps that depend on some external Postgres (as a dev dependency)

Basic summary:

  • Pip installable binaries: tested on Ubuntu and MacOS (apple silicon + x86), including pgvector extension.
  • No sudo needed: Does not require root or sudo.
  • Convenient startup: pgserver.get_server(MY_DATA_DIR) factory method to initialize data and server if needed, so you don't need to understand initdb, pg_ctl, port conflicts, and skip debugging why you still cannot connect to the server.
  • Convenient cleanup: server process cleanup is done for you, including when multiple independent processes call pgserver.get_server(MY_DATA_DIR)
  • Context manager protocol to explicitly control cleanup timing in testing scenarios.
  • For lower-level control, wrappers to all binaries, such as initdb, pg_ctl, psql, pg_config. Includes header files in case you wish to build some other extension and use it against these binaries.
# Example 1: postgres backed application
import pgserver

pgdata = f'{MY_APP_DIR}/pgdata'
db = pgserver.get_server(pgdata)
# server ready for connection.

print(db.psql('create extension vector'))
db_uri = db.get_uri()
# use uri with sqlalchemy / psycopg, etc

# if no other process is using this server, it will be shutdown at exit,
# if other process use same pgadata, server process will be shutdown when all stop.
# Example 2: Testing
import tempfile
import pytest
@pytest.fixture
def tmp_postgres():
    tmp_pg_data = tempfile.mkdtemp()
    with pgserver.get_server(tmp_pg_data, cleanup_mode='delete') as pg:
        yield pg

Postgres binaries in the package can be found in the directory pointed to by the pgserver.pg_bin global variable.

Based on https://github.com/michelp/postgresql-wheel, with the following differences:

  1. +Wheels for multiple platforms (+MacOS x86, +MacOS apple silicon)
  2. +Server management (initialization and cleanup including multi-process )
  3. +pgvector extension included
  4. -postGIS (many dependencies => harder to build cross platform. pull requests taken)

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

pgserver-0.0.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (14.9 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

pgserver-0.0.5-cp312-cp312-macosx_11_0_arm64.whl (13.1 MB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

pgserver-0.0.5-cp312-cp312-macosx_10_9_x86_64.whl (14.0 MB view details)

Uploaded CPython 3.12 macOS 10.9+ x86-64

pgserver-0.0.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (14.9 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

pgserver-0.0.5-cp311-cp311-macosx_11_0_arm64.whl (13.1 MB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

pgserver-0.0.5-cp311-cp311-macosx_10_9_x86_64.whl (14.0 MB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

pgserver-0.0.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (14.9 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

pgserver-0.0.5-cp310-cp310-macosx_11_0_arm64.whl (13.1 MB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

pgserver-0.0.5-cp310-cp310-macosx_10_9_x86_64.whl (14.0 MB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

pgserver-0.0.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (14.9 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

pgserver-0.0.5-cp39-cp39-macosx_11_0_arm64.whl (13.1 MB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

pgserver-0.0.5-cp39-cp39-macosx_10_9_x86_64.whl (14.0 MB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

pgserver-0.0.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (14.9 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

pgserver-0.0.5-cp38-cp38-macosx_11_0_arm64.whl (13.1 MB view details)

Uploaded CPython 3.8 macOS 11.0+ ARM64

pgserver-0.0.5-cp38-cp38-macosx_10_9_x86_64.whl (14.0 MB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

File details

Details for the file pgserver-0.0.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pgserver-0.0.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9a5b321c296674153fdf43991a0e4f8cc3e3489ad38850dacb1ef4c7ae030df0
MD5 20335b7397c3a62ea6f8241190f66d7d
BLAKE2b-256 a1a89f498354b9558a65a05524b502306334a72bac91634c59205dcc29a26c27

See more details on using hashes here.

File details

Details for the file pgserver-0.0.5-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pgserver-0.0.5-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c0832d9a312108e0f3cc495be20260b507c191cc9f8ed917768db8c3f043f7a6
MD5 344ce165174965528e182e0cc2596101
BLAKE2b-256 503fd5a6daaec156ef59ef4c626ec9185d8e5e5a742518d8713ccc6c175b04b4

See more details on using hashes here.

File details

Details for the file pgserver-0.0.5-cp312-cp312-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pgserver-0.0.5-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 96415c35dabf73d86a7d920e2a4a0c1adfa52818dc9035af26313929b9ab250e
MD5 ee86a6f94d0f25deda6a054ada5ef23d
BLAKE2b-256 c9d9eb5521a9fb5ee32f9f573ad779a2f5ad2ed03fd5b730c0a9ee29212c2e5d

See more details on using hashes here.

File details

Details for the file pgserver-0.0.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pgserver-0.0.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 44d1661847f9bd28a20a1d1a79ee7d5fdd5bf503e5f9a001d0137329bc52a0ea
MD5 223deedad55ff61612ce03886bba4606
BLAKE2b-256 9cf753015fa06ff3f794d105ffc66528c6279be2563f71d9ac93d136f5caffa8

See more details on using hashes here.

File details

Details for the file pgserver-0.0.5-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pgserver-0.0.5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f70c39727c4820f7c546068875e4c577bec5f1e39155446fe275e6d8c433155b
MD5 82ae47a629345a1af69c1feef5cf6538
BLAKE2b-256 0d4fdd1d36dfc6797c6bb2ab329aec042728cbbfd45b60588f0c1f7783c0974c

See more details on using hashes here.

File details

Details for the file pgserver-0.0.5-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pgserver-0.0.5-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 a0b292505610f313f65c96d60fc205cc556422933c8a571ff7a59d5a51a75e15
MD5 70743058c0dea2c542b6e1d07e77bd11
BLAKE2b-256 42fc9467c8a307bcda12ef575608fd6b7575d3f41c75f09ff7897fbe2298f6e6

See more details on using hashes here.

File details

Details for the file pgserver-0.0.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pgserver-0.0.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ca29cc90b4aaf98b6d81e23db8f7212aa233b13c9585d97c9ed7ee2da9b8a237
MD5 eefffc6a6cbdc017668c1e3589d569d6
BLAKE2b-256 c0d1d0fb320224ba54da83e2663bffe63d1a050d5bf01298d1152e3864954109

See more details on using hashes here.

File details

Details for the file pgserver-0.0.5-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pgserver-0.0.5-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7c6768e733ad1ceb373c12860a07bff6f31be2a3c43ad8a0c3c62764246030fa
MD5 e5cf064b333b250cdbe3f16c488ebbfd
BLAKE2b-256 b9c02accf840f4ad2a94a18070fde470261f2126613a1af0cefea6d3e03c3c46

See more details on using hashes here.

File details

Details for the file pgserver-0.0.5-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pgserver-0.0.5-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 84cca77054dfc5ff8c4499a874794df867b05daf8253fd37a5bafcfbc4dd303e
MD5 ceecbc9aae4678e1e00d747ea959246a
BLAKE2b-256 f88cde03d7d9f0a384dc6eec075a6b5e54984fd62b33bb95937d016e17c159e9

See more details on using hashes here.

File details

Details for the file pgserver-0.0.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pgserver-0.0.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d7491d3d8ad75dfdff4229832fa2397c82b6d7f9fb52fd1526794d07593b8685
MD5 c07b628b27f4a2ea6b92b1e59c65d560
BLAKE2b-256 15e6e8f024326ec5edf4e1236e7fbb5995291d9c077833cc43b57f6f675bd0b8

See more details on using hashes here.

File details

Details for the file pgserver-0.0.5-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pgserver-0.0.5-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4be3638c7f715d966c7ae0aa5b9151c5304ae9114427b7fb8137b28ec872bc88
MD5 6666e4482859737093cee0b43e5ea764
BLAKE2b-256 ad8ddb8c8aa2c83a24af1123dccaae770b60a0a79c9457f9445d09967736eb3c

See more details on using hashes here.

File details

Details for the file pgserver-0.0.5-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pgserver-0.0.5-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 341df574408c122bc80ae3beca3704d28dbd59cc0578cfcd83c854157fff3230
MD5 6bf0bb290ce95869ae0ff9fc82fb71a8
BLAKE2b-256 968b68d9e032291fea3241d05b2f430752f30f701616bcada917157ee5d42d16

See more details on using hashes here.

File details

Details for the file pgserver-0.0.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pgserver-0.0.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 12621ec0729e805ee63becf826e2adf74fa18ee01bbb4a251ff02f0f8efd4ce5
MD5 7af05aff8837ab61e7933f914101d894
BLAKE2b-256 c8a9e2621127b398e1cec83585fb47127ad4935e4214df2ea10942fb7158a190

See more details on using hashes here.

File details

Details for the file pgserver-0.0.5-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pgserver-0.0.5-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1f8892af1226549dd6cd734b108e90cfdcb614ee2b9e5c3d17d47d05fe92ca89
MD5 3f9b0f70ad865247ff8cb7f5cf88cedb
BLAKE2b-256 6b8095c3aa4bd0b7655adcbeec62c6cefd8b00e75c3b44095e242975df2d1870

See more details on using hashes here.

File details

Details for the file pgserver-0.0.5-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pgserver-0.0.5-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 244394b51b87e19145c602b2b03457d637a0cf88d82745504b99b72aa9cfd427
MD5 0034f2bf4261390cf8549d6b77627b9b
BLAKE2b-256 7d84b67379cbaf08d71305f574658dcb705cce2f75e7bcadddb8c8be3864c72f

See more details on using hashes here.

Supported by

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