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-13.4.12-pp37-pypy37_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (13.7 MB view details)

Uploaded PyPy manylinux: glibc 2.12+ x86-64

postgresql_wheel-13.4.12-pp37-pypy37_pp73-manylinux_2_12_i686.manylinux2010_i686.whl (14.4 MB view details)

Uploaded PyPy manylinux: glibc 2.12+ i686

postgresql_wheel-13.4.12-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (13.7 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.12+ x86-64

postgresql_wheel-13.4.12-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.whl (14.4 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.12+ i686

postgresql_wheel-13.4.12-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (13.7 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

postgresql_wheel-13.4.12-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.whl (14.4 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.12+ i686

postgresql_wheel-13.4.12-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (13.7 MB view details)

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

postgresql_wheel-13.4.12-cp37-cp37m-manylinux_2_12_i686.manylinux2010_i686.whl (14.4 MB view details)

Uploaded CPython 3.7m manylinux: glibc 2.12+ i686

File details

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

File metadata

File hashes

Hashes for postgresql_wheel-13.4.12-pp37-pypy37_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 9e22ec320b5e9948d39d98a39463f2edd34768fbc9f32f9dcf11f393bcc449de
MD5 6a767c3368550ef64db929bf97553d69
BLAKE2b-256 8c8b8aec6a87f9aea58e4ee2d594bfd568b84158352bc5aacd54cbe5f95c1104

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for postgresql_wheel-13.4.12-pp37-pypy37_pp73-manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm Hash digest
SHA256 07001f6086c6952ee8eac9c65ea133cc93d2917f2698f3c7288bc2ff78702c34
MD5 3b4b0db169cd720c9643fef4e122c8a1
BLAKE2b-256 fb370cbe67c44a1bc67e76e213f5f4112eaf16a466653f01891205199f7f98c5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for postgresql_wheel-13.4.12-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 ce24478e2090e60ca25bc62ca995c719254bd4f12700d464779134711fd3b4b7
MD5 c65180ef0bef2a7db089a250c5879d8b
BLAKE2b-256 40dd82bfc6dd294d8cd8de9986ea4a2b4563a8e2c86cf796c11843c3abd6bb7a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for postgresql_wheel-13.4.12-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm Hash digest
SHA256 191602b535c602323302377cf7426c29f6f38b4adb9bf2565f57093f90de51e0
MD5 b90d1a71aaaddf4dba6d22484cb3ac20
BLAKE2b-256 0e3de9dcf2990f2f1aa410374597a8607ff7b5ab4312286162856c1ff2103809

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for postgresql_wheel-13.4.12-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 9bf461088d6a671cd8541b77138223b8a287ce8e15b4a20f11841cb72586df94
MD5 29640b7d3545945f6125f47c3a6b9f6a
BLAKE2b-256 88adcc48b375ba6a0980a7038002fc2be4487f1b5080996786fce6b21b32f1be

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for postgresql_wheel-13.4.12-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm Hash digest
SHA256 ae6dc5df16ff872551a729e0fcf910d5ed5577500b95cb5314eb3640bdd744dd
MD5 8e9477a8e926b6b0acfef39c93752fde
BLAKE2b-256 aae8793c45369b165cebee5d44cc28b439949849377003b62ce15eebc98809d5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for postgresql_wheel-13.4.12-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 cb8731d430ad11167778b902b513e69de5b74a3668af7aed2f807ce585a68d2e
MD5 06e4f08bc7f40ac595bdece12ead88ab
BLAKE2b-256 8a10fe68b7c85136f7cd0f0413a730609f2de9c358dd212ef03e4b2cd79df0ae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for postgresql_wheel-13.4.12-cp37-cp37m-manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm Hash digest
SHA256 8b9ed81dd1ce298d4eabcaa3b7a104b2609825dfb955200a4711b82e3d4c3ff8
MD5 e8d1ad34bb65f81cd80dced745b614f5
BLAKE2b-256 e21832f4b4be44eb7474c18ea33ce357cc694acd6c6d326be5d9c205ec8edfea

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