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

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.7
File Actions
pgserver-0.0.7-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.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
pgserver-0.0.7-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details for pgserver-0.0.7-cp311-cp311-macosx_11_0_arm64.whl
pgserver-0.0.7-cp311-cp311-macosx_10_9_x86_64.whl CPython 3.11 CPython 3.11 macOS 10.9+ x86-64 Details for pgserver-0.0.7-cp311-cp311-macosx_10_9_x86_64.whl
pgserver-0.0.7-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.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
pgserver-0.0.7-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details for pgserver-0.0.7-cp310-cp310-macosx_11_0_arm64.whl
pgserver-0.0.7-cp310-cp310-macosx_10_9_x86_64.whl CPython 3.10 CPython 3.10 macOS 10.9+ x86-64 Details for pgserver-0.0.7-cp310-cp310-macosx_10_9_x86_64.whl
pgserver-0.0.7-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.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
pgserver-0.0.7-cp39-cp39-macosx_11_0_arm64.whl CPython 3.9 CPython 3.9 macOS 11.0+ ARM64 Details for pgserver-0.0.7-cp39-cp39-macosx_11_0_arm64.whl
pgserver-0.0.7-cp39-cp39-macosx_10_9_x86_64.whl CPython 3.9 CPython 3.9 macOS 10.9+ x86-64 Details for pgserver-0.0.7-cp39-cp39-macosx_10_9_x86_64.whl

Total release size: 126.3 MB

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

Download URL pgserver-0.0.7-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
23dbca7e7e1231c4a287f819c89458b1828751ca8426bf2e3b10e171e8aaf089
BLAKE2b-256 checksum
How to use checksums
f726eb5edfc5d884592f6915e10dcb59c796c28e001d454c04fe5dbffdb9c68f
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.7-cp311-cp311-macosx_11_0_arm64.whl

Download URL pgserver-0.0.7-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
7a7e0f76099780cc7fedc9811a7bd4ab5b5fe40790ffafd5e3b3de0323c1bb82
BLAKE2b-256 checksum
How to use checksums
482f49605bcfda1359d66f2423880541d11f760eb2e6885a66062595186babd3
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.7-cp311-cp311-macosx_10_9_x86_64.whl

Download URL pgserver-0.0.7-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
5c7a504d0152e76939b3430bff91739e03a5b7f03e651e51715b1617aa09a400
BLAKE2b-256 checksum
How to use checksums
8ed9522d59a38b0b625e4bacfeb848c7e990a2b8223d5de8515a2623d1686753
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.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pgserver-0.0.7-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
13ef11fb24ba35068b1dc997f31ac3b1223fb5f323bdc236f059cb7ae53f22f7
BLAKE2b-256 checksum
How to use checksums
e18c4c86e457085c82c763ed0466e445313ce6c61b411ba791e664b009002190
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.7-cp310-cp310-macosx_11_0_arm64.whl

Download URL pgserver-0.0.7-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
d4325c33d514cdc0aef8735330e08071f8c953a11cc732e15a162452a122de1e
BLAKE2b-256 checksum
How to use checksums
3d3b4afb0964af04fc06ea68c4b412019c7247034cc39f475a726b23d1632e72
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.7-cp310-cp310-macosx_10_9_x86_64.whl

Download URL pgserver-0.0.7-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
2122113afa8aab14ff10848c2c8dbe575359adef834ec74401dca4aa8cc24261
BLAKE2b-256 checksum
How to use checksums
f0dfb0a5d68927c896025a13c6b03ca9f59fbe537601dff459e881b7344bdabb
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.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pgserver-0.0.7-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
dc3bcd5687f5cabe9e83ee1d7914c03a918cdb967f94aa91cc6ec12c44884750
BLAKE2b-256 checksum
How to use checksums
870400895bc3a8bc8df10b27d7c452c7e4e866900cca81a5a84f158572e0fde1
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.7-cp39-cp39-macosx_11_0_arm64.whl

Download URL pgserver-0.0.7-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
b3f376f4dc8a749785d90cb46be92d31a1e46024fb2cf6ca2d2d62576a59b1c8
BLAKE2b-256 checksum
How to use checksums
e1df74a6625630562cfeda404c3615c02767824141cfded1c65a612a9edf9ad4
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.7-cp39-cp39-macosx_10_9_x86_64.whl

Download URL pgserver-0.0.7-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
6d0e4500c5caaaf34af66cf5b3e9e19646fba53033a20c4fafd4e98e59315999
BLAKE2b-256 checksum
How to use checksums
c528353525f0331c11326c6208eb2d7d02d420e303a7944189c28291fc71117e
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.7

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