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
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
File details
Details for the file postgresql_wheel-13.4.13-pp37-pypy37_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
.
File metadata
- Download URL: postgresql_wheel-13.4.13-pp37-pypy37_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
- Upload date:
- Size: 13.7 MB
- Tags: PyPy, manylinux: glibc 2.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89be49d401d4cc79f48d3382d225155871ca82c66e25d0fefd8fc77566c7bd84 |
|
MD5 | 4b43c69379899f165d871874b3642a23 |
|
BLAKE2b-256 | aa306c6220691f856546fbf57fd069d663dc85e38e2f1cdc75c02281e0a1aca2 |
File details
Details for the file postgresql_wheel-13.4.13-pp37-pypy37_pp73-manylinux_2_12_i686.manylinux2010_i686.whl
.
File metadata
- Download URL: postgresql_wheel-13.4.13-pp37-pypy37_pp73-manylinux_2_12_i686.manylinux2010_i686.whl
- Upload date:
- Size: 14.4 MB
- Tags: PyPy, manylinux: glibc 2.12+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b875a3d66e53ea2de44239bcd97b8542f2e161a5dd8e5233ced2ce271a4fbed |
|
MD5 | 85e8346dcce6b3de9e55c0ec505a8cea |
|
BLAKE2b-256 | 5c4dcc035940682a5f918bac4136783ba33b8e0261b1d7f966f28d5ab640829b |
File details
Details for the file postgresql_wheel-13.4.13-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
.
File metadata
- Download URL: postgresql_wheel-13.4.13-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
- Upload date:
- Size: 13.7 MB
- Tags: CPython 3.9, manylinux: glibc 2.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f3a9564dfeef825a7dcec0b2ce2ef848b26fc4272a3dca6a9eea1196c436f79 |
|
MD5 | 615c6dd8ee8d2836ffaadd1109c7b58a |
|
BLAKE2b-256 | ac50de96c21749dab354896fbb1fd86a86c71ccb2f07f6c3c313b5e9afd6c3ed |
File details
Details for the file postgresql_wheel-13.4.13-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.whl
.
File metadata
- Download URL: postgresql_wheel-13.4.13-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.whl
- Upload date:
- Size: 14.4 MB
- Tags: CPython 3.9, manylinux: glibc 2.12+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aae93573cc4256be72bee9d611d291d1f5a538c7ede1631db5e0cf4a0fef8c04 |
|
MD5 | 91094be7f171e0f8dc465f34e5c63a01 |
|
BLAKE2b-256 | da219c71f7cef669ae4a2060f7193c2fccff8a64e99e5776722af3c0a5ac91ad |
File details
Details for the file postgresql_wheel-13.4.13-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
.
File metadata
- Download URL: postgresql_wheel-13.4.13-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
- Upload date:
- Size: 13.7 MB
- Tags: CPython 3.8, manylinux: glibc 2.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55cc35f1fca891241cbf3f30835f0ec112c4e68ecbcae59822a849af74902c93 |
|
MD5 | 68a59af9cd938375c80189e9513d5860 |
|
BLAKE2b-256 | 1683b4e50cae46feee775d88d5ee0cbce12c5f6a598e0d2fc97cf6fcd84e989d |
File details
Details for the file postgresql_wheel-13.4.13-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.whl
.
File metadata
- Download URL: postgresql_wheel-13.4.13-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.whl
- Upload date:
- Size: 14.4 MB
- Tags: CPython 3.8, manylinux: glibc 2.12+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27246c3d98f37716c3ecaf70146e6fb08940ee3b4f535e6beebe910454981ce7 |
|
MD5 | a64b63e58426952437a22e6ac62107cf |
|
BLAKE2b-256 | 5af11150c9ccbc63785692cedae97d5999f2d0788cc9b5ca39b25aaf3b6e09d5 |
File details
Details for the file postgresql_wheel-13.4.13-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
.
File metadata
- Download URL: postgresql_wheel-13.4.13-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
- Upload date:
- Size: 13.7 MB
- Tags: CPython 3.7m, manylinux: glibc 2.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3bbc420c21f2402824557c81c9d4d528f7d9e87a5804b16bb8ee676e6b1b925 |
|
MD5 | f8faff24ab4338199bf5d5ef68c20a13 |
|
BLAKE2b-256 | cc808b6e9d52b51737f1c3ddcc288a28e8370c0ac0faa90cfc7f8ced02c0f727 |
File details
Details for the file postgresql_wheel-13.4.13-cp37-cp37m-manylinux_2_12_i686.manylinux2010_i686.whl
.
File metadata
- Download URL: postgresql_wheel-13.4.13-cp37-cp37m-manylinux_2_12_i686.manylinux2010_i686.whl
- Upload date:
- Size: 14.4 MB
- Tags: CPython 3.7m, manylinux: glibc 2.12+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 361aa2794bda2ea42d1c8958591d1161cc56b40f8ab147ee547fd4d0b9affec2 |
|
MD5 | 9d7d5d9a45ae68e7bb83b7786fbd129c |
|
BLAKE2b-256 | 876ec055e80da238d3c1ec9c5d1413c468465f4b7af6db17be1ea29443360145 |