Skip to main content

Self-contained postgres server for your python applications

Project description

pgserver: pip-installable postgres + pgvector for your python app

pip install pgserver

pgserver lets you initialize (if needed) and run a Postgres server associated with a data dir within your Python app, with server binaries included. Wheels are built for multiple platforms.

Example use cases:

  • The main motivation is to enable building Postgres-backed python apps that remain pip-installable, saving you and, more importantly, your users any need to install and setup postgres.
  • The second advantage is avoid remembering how to set-up a local postgres server, instead you immediately get a sqlalchemy or psql usable URI string and get to work.
  • Also possible: 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.
  • Simpler initialization: pgserver.get_server(MY_DATA_DIR) 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, just do server.get_uri() to connect. Uses unix domain sockets to avoid port conflicts.
  • Convenient cleanup: server process cleanup is done for you: when the process using pgserver ends, the server is shutdown, including when multiple independent processes call pgserver.get_server(MY_DATA_DIR) on the same dir (wait for last one)
    • includes 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, but with the following differences:

  1. Wheels for multiple platforms (ubuntu x86, +MacOS x86, +MacOS apple silicon), pull requests taken for ubuntu arm.
  2. pgvector extension included
  3. postgres Server management: cleanup via shared count when multiple processes use the same server.
  4. no postGIS (need 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.8-cp311-cp311-win_amd64.whl (16.3 MB view details)

Uploaded CPython 3.11 Windows x86-64

pgserver-0.0.8-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (15.0 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

pgserver-0.0.8-cp311-cp311-macosx_13_0_arm64.whl (13.1 MB view details)

Uploaded CPython 3.11 macOS 13.0+ ARM64

pgserver-0.0.8-cp311-cp311-macosx_12_0_x86_64.whl (14.0 MB view details)

Uploaded CPython 3.11 macOS 12.0+ x86-64

pgserver-0.0.8-cp310-cp310-win_amd64.whl (16.3 MB view details)

Uploaded CPython 3.10 Windows x86-64

pgserver-0.0.8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (15.0 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

pgserver-0.0.8-cp310-cp310-macosx_13_0_arm64.whl (13.1 MB view details)

Uploaded CPython 3.10 macOS 13.0+ ARM64

pgserver-0.0.8-cp310-cp310-macosx_12_0_x86_64.whl (14.0 MB view details)

Uploaded CPython 3.10 macOS 12.0+ x86-64

pgserver-0.0.8-cp39-cp39-win_amd64.whl (16.3 MB view details)

Uploaded CPython 3.9 Windows x86-64

pgserver-0.0.8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (15.0 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

pgserver-0.0.8-cp39-cp39-macosx_13_0_arm64.whl (13.1 MB view details)

Uploaded CPython 3.9 macOS 13.0+ ARM64

pgserver-0.0.8-cp39-cp39-macosx_12_0_x86_64.whl (14.0 MB view details)

Uploaded CPython 3.9 macOS 12.0+ x86-64

File details

Details for the file pgserver-0.0.8-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: pgserver-0.0.8-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 16.3 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for pgserver-0.0.8-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 144a040851779ec8f87aa38aec70584bcf4905b4f684ad673c41b85de2c1c646
MD5 0e083fae27e572ce12d703b81e3f8e2f
BLAKE2b-256 a190a3f89381d8b0e9f600a1233d87a268ed870e7f74e09cd7687609c513f0f2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgserver-0.0.8-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 dc9c1e6a9425682aa89590267ffb156bd734285dbd12aa2a30a90ba1729d2a05
MD5 40840e974bf09939cbb854ec59811a5b
BLAKE2b-256 03d908f87fe9c0d2447c199db0e97c1ebb9080bee0bd66fb85d11ea40dc65136

See more details on using hashes here.

File details

Details for the file pgserver-0.0.8-cp311-cp311-macosx_13_0_arm64.whl.

File metadata

File hashes

Hashes for pgserver-0.0.8-cp311-cp311-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 ca44073676fd9ee743c57b00ef7ce3f33f5e6bbe236f1d4a4fc533ac27ebb153
MD5 84e8bb53bd6bb8aa76ddcce3f78446c1
BLAKE2b-256 b99eb2e917bdc19f7abb2b9b7fa53f1500629a3ae2efe78c85011b3918a801b3

See more details on using hashes here.

File details

Details for the file pgserver-0.0.8-cp311-cp311-macosx_12_0_x86_64.whl.

File metadata

File hashes

Hashes for pgserver-0.0.8-cp311-cp311-macosx_12_0_x86_64.whl
Algorithm Hash digest
SHA256 8afe186e7334fa4d98bf1d695596e14e8fad8349d2fb32133d0e15415970b48a
MD5 9bbffcbe840ea462cfb1d346b78ee85b
BLAKE2b-256 aec5d970af2366c86166cc662ab7c1c8bacc1404a05fcd154c93e8c938e29414

See more details on using hashes here.

File details

Details for the file pgserver-0.0.8-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: pgserver-0.0.8-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 16.3 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for pgserver-0.0.8-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 e5dd14c1589a8655663f7cbb2c566744a2539d95fb3c830dd46fa62dd38265e0
MD5 0b1e6efbcd98843a2a584bba383444b5
BLAKE2b-256 24763acd538477e03842ac72a61b6dd78185e837dd859b5d852421a64d228b99

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgserver-0.0.8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f32d6c0b9ea2af47287212c98599844bfe3a9f882d52c123b150503385f5f65c
MD5 2e36a302ba3309607f5a6abc2b854076
BLAKE2b-256 b3680569826c9878bf9c917b49311d39a19a6fd1c9e999a59959b373d39b44c2

See more details on using hashes here.

File details

Details for the file pgserver-0.0.8-cp310-cp310-macosx_13_0_arm64.whl.

File metadata

File hashes

Hashes for pgserver-0.0.8-cp310-cp310-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 dce5a29fa874745049067622ea341e729dfe3f096a8fe58063c178a250eb65cf
MD5 b00971866bb1c4915b61f98591eb2d8f
BLAKE2b-256 f800c5e2b1d53ca7ae11845746c83c67bbbf46e0e9db17c1fa018240f93ea277

See more details on using hashes here.

File details

Details for the file pgserver-0.0.8-cp310-cp310-macosx_12_0_x86_64.whl.

File metadata

File hashes

Hashes for pgserver-0.0.8-cp310-cp310-macosx_12_0_x86_64.whl
Algorithm Hash digest
SHA256 6725b5319edf638395ba318d2ab798903d42b8792a254412298cf5f8d7b6070c
MD5 e1123bb65a8dba9041f0604b19b4330d
BLAKE2b-256 82707fc3fc377d2b664e65efd7c823373f0bfc6dd96618ac2a287083c3dec896

See more details on using hashes here.

File details

Details for the file pgserver-0.0.8-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: pgserver-0.0.8-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 16.3 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for pgserver-0.0.8-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 15ad8c802b211ef614daf6f405514338d1daa609fdb32db9d885dfbf55a280d8
MD5 792ef7978d6f602d4f5802c7eec005ff
BLAKE2b-256 5b309939ef73a45b540a954facbf1c3c230240c34d55346cc70e199bf02fd31a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgserver-0.0.8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b6b937bd68a8624cc3b61059314c797aaf3da3fa1ee418c5113d67e3bf36d9fe
MD5 401094577294c65b6921b5c64600b1b8
BLAKE2b-256 2935c0d97b5639cff8ce01a1b3d2c4e77e75cb620f598084a7e0ca799479d319

See more details on using hashes here.

File details

Details for the file pgserver-0.0.8-cp39-cp39-macosx_13_0_arm64.whl.

File metadata

File hashes

Hashes for pgserver-0.0.8-cp39-cp39-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 1a1a019023b6359f175c2a7dd5513627d864939c2200f8b454bcf5f97d2176ba
MD5 986b8bb65324076038de2dc6647df23e
BLAKE2b-256 108cadb5a263ec37bedc3e9be681d2a10da1eeacb4dfbb86c86798b6c1778db7

See more details on using hashes here.

File details

Details for the file pgserver-0.0.8-cp39-cp39-macosx_12_0_x86_64.whl.

File metadata

File hashes

Hashes for pgserver-0.0.8-cp39-cp39-macosx_12_0_x86_64.whl
Algorithm Hash digest
SHA256 385942d678480255711e9b5a950030a3062fa6cd80d4fbd283b684bb66f934ab
MD5 f862ce578dba707873a188c76aeb72f2
BLAKE2b-256 ffb830a5f12a6aa689af3db40997ced9f59d595bac808a9127bf2eeb76b5cc7b

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