Skip to main content

PostgreSQL Server compiled into a Python Wheel.

Project description

postgresql-wheel

A Python wheel for Linux containing a complete, self-contained, locally installable PostgreSQL database server.

All servers run as the Python process user in a local path, so this wheel does not require root or sudo privledges. Databases can be initialized in any directory.

Servers can be setup and torn down in test fixtures with no additional outside dependencies.

Currently this wheel only works for most flavors of Linux.

Postgres is compiled in the same "manylinux" environments provided by the cibuildwheel tool using Github Actions and directly archived into the wheel's "package_data".

The wheel can be installed with pip:

$ pip install postgresql-wheel

Postgres binaries in the package can be found in the directory pointed to by the postgresql.pg_bin global variable. Function wrappers around all of the postgres binary programs, like initdb and pg_ctl functions are provided for convenience:

>>> from postgresql import initdb, pg_ctl
>>> initdb('-D testdatabase')
>>> pg_ctl('-D testdatabase -o "-p 5678" -l testdatabase.log start')

>>> import psycopg2
>>> c = psycopg2.connect("postgres://localhost:5678/postgres") # connect with local client
>>> with c.cursor() as q:
>>>     q.execute("select version()")
>>>     print(q.fetchall())
...
[('PostgreSQL 13.4 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.3.1 20190311 (Red Hat 8.3.1-3), 64-bit',)]
>>> pg_ctl('-D testdatabase stop)

For the purposes of testing, convenience functions are provided for setting up and tearing down databases:

>>> pgdata, con_str = postgresql.setup()
>>> postgresql.psql(f'-h {con_str} -c "select version()"')
>>> postgresql.teardown(pgdata)

There is also a pytest fixture called tmp_postgres that returns a new connection string to a temporary databse local domain socket, and can be used in a pytest:

>>> from postgresql import tmp_postgres
>>> def test_foo(tmp_postgres):
...    postgresql.psql(f'-h {tmp_postgres} -c "select version()")

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

postgresql_wheel-11.13.0-pp37-pypy37_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (12.7 MB view details)

Uploaded PyPy manylinux: glibc 2.12+ x86-64

postgresql_wheel-11.13.0-pp37-pypy37_pp73-manylinux_2_12_i686.manylinux2010_i686.whl (13.2 MB view details)

Uploaded PyPy manylinux: glibc 2.12+ i686

postgresql_wheel-11.13.0-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (12.7 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.12+ x86-64

postgresql_wheel-11.13.0-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.whl (13.2 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.12+ i686

postgresql_wheel-11.13.0-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (12.7 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

postgresql_wheel-11.13.0-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.whl (13.2 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.12+ i686

postgresql_wheel-11.13.0-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (12.7 MB view details)

Uploaded CPython 3.7m manylinux: glibc 2.12+ x86-64

postgresql_wheel-11.13.0-cp37-cp37m-manylinux_2_12_i686.manylinux2010_i686.whl (13.2 MB view details)

Uploaded CPython 3.7m manylinux: glibc 2.12+ i686

File details

Details for the file postgresql_wheel-11.13.0-pp37-pypy37_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for postgresql_wheel-11.13.0-pp37-pypy37_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 fd4f056eb56644aea147bd855d43fe02fb5e4a749a85eb04a8a705ef6c57c4f9
MD5 649697a580c6f12dd16269782231b45f
BLAKE2b-256 d1c4c56d49a4756b58fa601dbacf3ec02a2133d6b31694d2d781ba36128e2b9b

See more details on using hashes here.

File details

Details for the file postgresql_wheel-11.13.0-pp37-pypy37_pp73-manylinux_2_12_i686.manylinux2010_i686.whl.

File metadata

File hashes

Hashes for postgresql_wheel-11.13.0-pp37-pypy37_pp73-manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm Hash digest
SHA256 b3dc6245a022276a01463c34e20ef63498a6395f4cf16a7ac55b31cc0b740c48
MD5 c21105c94d77149222de7237cccb4926
BLAKE2b-256 ef1d1dc0385ecd83502387243f27f7f8a872e90dd69d73a624e7c3e525fae0e2

See more details on using hashes here.

File details

Details for the file postgresql_wheel-11.13.0-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for postgresql_wheel-11.13.0-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 fb18196e241929d7d4fc29e82e5b26ae51449eeceda2ae782da67fb09a124121
MD5 e091245cdb2d5f984dfc49e3f126a3c0
BLAKE2b-256 cb8a22ae9be29562cb8c010886cb3368c27bceffb92a6af7b0890d6cca01a9ea

See more details on using hashes here.

File details

Details for the file postgresql_wheel-11.13.0-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.whl.

File metadata

File hashes

Hashes for postgresql_wheel-11.13.0-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm Hash digest
SHA256 3003fee100aaa6a672c4a987abab9f2f52ad4772f2af1a56532cb540167fd36d
MD5 12503c80adb89228209bf95c8379cf77
BLAKE2b-256 7210f182813ca95dcc1a4a0e0910899fa5025b31ad5e6f45ca512d4c55e8669c

See more details on using hashes here.

File details

Details for the file postgresql_wheel-11.13.0-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for postgresql_wheel-11.13.0-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 cd29ec25670080247a923421c36901de72a1b5e8241a8f42002151bace3f10eb
MD5 d3d552e06fba96e95a661e8452050b72
BLAKE2b-256 d9012a09002753bd33b9ad9439da56878bbc58546f0f3cbe55a3622f719a4b6e

See more details on using hashes here.

File details

Details for the file postgresql_wheel-11.13.0-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.whl.

File metadata

File hashes

Hashes for postgresql_wheel-11.13.0-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm Hash digest
SHA256 728ffaab94218fd461918b8194c801f4e1c0f1a0395d2e5c22a353cbd49771f4
MD5 052de9f82c4b42e6307bdbd7b33aba71
BLAKE2b-256 f450061ac2d114122c5a0acc138e8a2fbde4fedbc5c2d49d1be2ded4c479d121

See more details on using hashes here.

File details

Details for the file postgresql_wheel-11.13.0-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for postgresql_wheel-11.13.0-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 b9702f3eef1e053c2789f1dbae5208b694d6cf9e59128fa52ee73c2bf9d35218
MD5 ada1886b49d0b3d8350ae87e2cca9948
BLAKE2b-256 b583bd23d91dc540e589ccd8f79e0e278220a42d4af761f00a872b874561ce29

See more details on using hashes here.

File details

Details for the file postgresql_wheel-11.13.0-cp37-cp37m-manylinux_2_12_i686.manylinux2010_i686.whl.

File metadata

File hashes

Hashes for postgresql_wheel-11.13.0-cp37-cp37m-manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm Hash digest
SHA256 bc30eff7f6f3a0f02ccaac17455124dbf7164adb274e268fa5da7c4645f5043d
MD5 de9bfafb1b4db7ca4d59bebecf6db086
BLAKE2b-256 fde7e77522c59cf52f35fda8521ad1b53b1fb798d29a328df1274367ec833be5

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