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 database 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for postgresql_wheel-14.1.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e4512e35ed650d0b7bb2381186d00cb9164d4ac274c1808b862cf2cda611fd1 |
|
MD5 | fd8e1aab98d4797255181e51a05ebaec |
|
BLAKE2b-256 | 554f1bf2c331e531c82b2b395bf0c833105e53a64d550171e3990f4f1397cf47 |
Hashes for postgresql_wheel-14.1.0-pp38-pypy38_pp73-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3d25f30d371c50fd840f4e815d59a5da764c8f061544f665139e681ca2b4983 |
|
MD5 | 21fd04e5a607cad0fd5dbe9fd598bcfd |
|
BLAKE2b-256 | ff14d044ac33d075d27299f476790f49a0ed8935c8345f20da06d925546a29f6 |
Hashes for postgresql_wheel-14.1.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ae2a1b0a7dc7c66668213d13945797f9f93ee19158b2410f6800355c337866d |
|
MD5 | cf5e50931d8615edb79cb8e893ba0c00 |
|
BLAKE2b-256 | 97e2a65332607c2489b037ad9dc4d6206a541bdb2d31d7f870c6a6484872afad |
Hashes for postgresql_wheel-14.1.0-pp37-pypy37_pp73-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 689f40b6082b33180887971157850afe9035a8729479f286e95326bf4538f35a |
|
MD5 | 2d9a66f9e48e885240f1261ad4bcb837 |
|
BLAKE2b-256 | 8f5a4affa901ecfef91572922bc42acc9c45a00c8616ab0fa973653125be2fcd |
Hashes for postgresql_wheel-14.1.0-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 773223ab51c3bea9cbd1e796af7c6c4c96a7f5cdd842ffb6536b3efecb44b03e |
|
MD5 | 444dc4b10402f2a93f73eca0c9b5b30e |
|
BLAKE2b-256 | d3ef78290000d1a05a14facc1bbad7d3cf034eea6b5767f4af82f55b65e72270 |
Hashes for postgresql_wheel-14.1.0-cp39-cp39-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e88f2de7be4310802dfc1d91f7685e2cefd7b000355e9b6dcb9246fc8c558cf |
|
MD5 | 3e309153a074e9eee885c53d51156101 |
|
BLAKE2b-256 | bd21557c38596432cd43ad19da79cd7b93f3f73026ea1befd21fc7e8ed29e592 |
Hashes for postgresql_wheel-14.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7bb85b50a5db5cce817371c9afb7eb7d330de8eddbaded98795d2b05d4b185d0 |
|
MD5 | 78758424e7f6c491fac49fc03a948ad6 |
|
BLAKE2b-256 | d7300ba05bc07f2fa266942033316fd6f1bced45c12f0937931db3b735baae2d |
Hashes for postgresql_wheel-14.1.0-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d37e71822061267410bbc1da518489353fbcc35d9eb3add20e883be9b4e73d65 |
|
MD5 | 16f5c51e0095c1e4b32d5ab3dfe1f3ad |
|
BLAKE2b-256 | 11ea3abad25e32a7125fe5f79d6b56a7754e2d2fa8c8994a5629041a5bc74ae7 |
Hashes for postgresql_wheel-14.1.0-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2fa45d84338a44bffd851ed0a5dea9f6df367e243ceeae0b648f018eea72382 |
|
MD5 | a34112076b1baf564a2375326cb3678d |
|
BLAKE2b-256 | e4420f122aebcbda6f529decebb0398cc94328e1f7eaa377f1817c19499c5846 |
Hashes for postgresql_wheel-14.1.0-cp38-cp38-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cabc7f004a8676b7a0c203d3709a8e8f24ca7a09aff9db0331e0275e1f0c2af3 |
|
MD5 | 347772093688b7922b5db700e3cb5d47 |
|
BLAKE2b-256 | d1ee3c7ba0ebff361b4f63249138698d64c746f91de7298c2b6f6bc00568a0a8 |
Hashes for postgresql_wheel-14.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d5a2b5f9b17829810eb1bf4bb708141b3194770cbe821d5ab78fd79e1469283 |
|
MD5 | 2612dc766510a606f6ff29722c47f26b |
|
BLAKE2b-256 | 4f798f7c84f0cb541bbe8b6914952a0582c1e1e8d6d1e97a924f0cde8bddb8e1 |
Hashes for postgresql_wheel-14.1.0-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b2edef3a206d200ddfa41b706d472964ddd5e60a4dd9984b1a603f9777e5eca5 |
|
MD5 | d53c96cf47b4e8ae75754b55b5fa6ccc |
|
BLAKE2b-256 | 8602236f066f090b8a1ed89dc72c82e0a045e6eab933082bfb7d58b59c78f8bc |
Hashes for postgresql_wheel-14.1.0-cp37-cp37m-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5cbe9b27a813898a8ea247fc361ecddd85eab348370d49b9a015399468dd54e7 |
|
MD5 | 0245a3c72167d6795a9854aab9c56e62 |
|
BLAKE2b-256 | 7a806ad3376b40ec87c95be8697e320e6027ebd932e423c7be3fd406b8cd24c3 |
Hashes for postgresql_wheel-14.1.0-cp37-cp37m-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 434677bd3a486bcf9f7f1977e490da037d73c1d1bf263fcf077a2fc76ed7bdec |
|
MD5 | e53384831194598b14c58a3b1dd3492a |
|
BLAKE2b-256 | 710a45a82012a652b9f1fc7ccd6453801d450e05da74c2e74d35f1e31126d453 |
Hashes for postgresql_wheel-14.1.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aff30c792b65d5fce55038ed7386577f9f0cd7a34375a322a84cd33903e0eb10 |
|
MD5 | 18b9ec9ff373b70563d1caf0cf24beb0 |
|
BLAKE2b-256 | 3b2364d3ea1c2daf4b87e1e57ea11ad3ad7963cb2021326bbecac97a51d37c15 |
Hashes for postgresql_wheel-14.1.0-cp37-cp37m-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5260e29a6599c753e5e7955934df79780feabdf403ffaa7ed6deef4accf6779c |
|
MD5 | c89904805d9273e67b544c118e3a7f53 |
|
BLAKE2b-256 | 00d2e551d2cea76113c0149cb06d5b6401ee14acd1af74a62b8555fde7a1d0d2 |