Skip to main content

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)

Metadata

Release files for pgserver 0.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for pgserver 0.0.6
File Actions
pgserver-0.0.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64 Details for pgserver-0.0.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
pgserver-0.0.6-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details for pgserver-0.0.6-cp311-cp311-macosx_11_0_arm64.whl
pgserver-0.0.6-cp311-cp311-macosx_10_9_x86_64.whl CPython 3.11 CPython 3.11 macOS 10.9+ x86-64 Details for pgserver-0.0.6-cp311-cp311-macosx_10_9_x86_64.whl
pgserver-0.0.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-64 Details for pgserver-0.0.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
pgserver-0.0.6-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details for pgserver-0.0.6-cp310-cp310-macosx_11_0_arm64.whl
pgserver-0.0.6-cp310-cp310-macosx_10_9_x86_64.whl CPython 3.10 CPython 3.10 macOS 10.9+ x86-64 Details for pgserver-0.0.6-cp310-cp310-macosx_10_9_x86_64.whl
pgserver-0.0.6-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.17+ x86-64 Details for pgserver-0.0.6-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
pgserver-0.0.6-cp39-cp39-macosx_11_0_arm64.whl CPython 3.9 CPython 3.9 macOS 11.0+ ARM64 Details for pgserver-0.0.6-cp39-cp39-macosx_11_0_arm64.whl
pgserver-0.0.6-cp39-cp39-macosx_10_9_x86_64.whl CPython 3.9 CPython 3.9 macOS 10.9+ x86-64 Details for pgserver-0.0.6-cp39-cp39-macosx_10_9_x86_64.whl

Total release size: 126.3 MB

Release files / pgserver-0.0.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pgserver-0.0.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 15.0 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
20de83673a5ff1cb6309f86a1f1c4b21d19ef8179b64eea713c56a1d0001aea1
BLAKE2b-256 checksum
How to use checksums
bac0fe5a6133b3699fc029db777d6eaaecdecf53574df6644c158f81abcb4098
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.2

Release files / pgserver-0.0.6-cp311-cp311-macosx_11_0_arm64.whl

Download URL pgserver-0.0.6-cp311-cp311-macosx_11_0_arm64.whl
Size 13.1 MB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
b930f9e01ada7fdf22f1dc1f17ced34819af328ff99644800afe5e43e230640c
BLAKE2b-256 checksum
How to use checksums
0609ee847b398679561da4b1d387e4c981e674557899eb2fe51bebf54707c174
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.2

Release files / pgserver-0.0.6-cp311-cp311-macosx_10_9_x86_64.whl

Download URL pgserver-0.0.6-cp311-cp311-macosx_10_9_x86_64.whl
Size 14.0 MB
Tags CPython 3.11 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
cbfe013d6cc6c9b0ff4008f923d396cda7b61a1406a89229edfc6fb94f7ed2a9
BLAKE2b-256 checksum
How to use checksums
0d8e2f880bae6dd3f0b8eb77f8e271d5514b00a309ffad2d12290e8639f30ba8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.2

Release files / pgserver-0.0.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pgserver-0.0.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 15.0 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
bf6bd3f2fb07e877a83a298f25ab55efb759482c0997c4bf7a34c53d373cb849
BLAKE2b-256 checksum
How to use checksums
4045ce7ce9f97a1fb561d2caf2ff85466973a4800df49cd0015eb0bda375fb7f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.2

Release files / pgserver-0.0.6-cp310-cp310-macosx_11_0_arm64.whl

Download URL pgserver-0.0.6-cp310-cp310-macosx_11_0_arm64.whl
Size 13.1 MB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
93d9cf5c9218684063d4348566943f9108dbd4430b1006d27cd5349c8f59db87
BLAKE2b-256 checksum
How to use checksums
af8e25727bb7fa09accec156bde4ed651841b05eb26cc7a4c7b47b815d863f1e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.2

Release files / pgserver-0.0.6-cp310-cp310-macosx_10_9_x86_64.whl

Download URL pgserver-0.0.6-cp310-cp310-macosx_10_9_x86_64.whl
Size 14.0 MB
Tags CPython 3.10 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
430270719fccf3873d476a88795e517ce0c9069b92946c97c60abc567796d20a
BLAKE2b-256 checksum
How to use checksums
6bc45561cf27c31b4ea01a3c1c4b754fd5dbee846c2e4a8b8eee38eee3f39243
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.2

Release files / pgserver-0.0.6-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pgserver-0.0.6-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 15.0 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
ad27a1abe360f41518fcd4b94453fce2dd4a97c587594045d9fb6228bc5694c7
BLAKE2b-256 checksum
How to use checksums
7e56b40d5df06cd4a65a3d87f505ffdaa0d5ecf6d0160222754483a44b326f8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.2

Release files / pgserver-0.0.6-cp39-cp39-macosx_11_0_arm64.whl

Download URL pgserver-0.0.6-cp39-cp39-macosx_11_0_arm64.whl
Size 13.1 MB
Tags CPython 3.9 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
0214411395809a70fcbb6894cc19570c2011de67030122563908b20890e432a4
BLAKE2b-256 checksum
How to use checksums
ca4bf6dbfa26b8af12d3c9b55ecbff97da1b1a43cfea8d262dd4e4b796b22fa7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.2

Release files / pgserver-0.0.6-cp39-cp39-macosx_10_9_x86_64.whl

Download URL pgserver-0.0.6-cp39-cp39-macosx_10_9_x86_64.whl
Size 14.0 MB
Tags CPython 3.9 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
5b60cc7345fcf89ecf8cf63a2b5bd2fc36654a127fca065ee651ecd8d9905a09
BLAKE2b-256 checksum
How to use checksums
ba1ce26baea00c2f8014d97e3e6211051c56427f2a22dc9062123eba428997e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.2

Security for pgserver 0.0.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page