Fixture to bring up temporary pgbouncer instance.
Project description
Copyright (c) 2011, Canonical Ltd
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
python-pgbouncer provides a python interface to setup and run a pgbouncer instance.
Dependencies
Python 3.5+
pgbouncer
psycopg2 (https://pypi.org/project/psycopg2)
python-fixtures (https://launchpad.net/python-fixtures or https://pypi.org/project/fixtures)
testtools (https://pypi.org/project/testtools)
Testing Dependencies
In addition to the above, the tests also depend on:
postgresfixture (https://pypi.org/project/postgresfixture)
testscenarios (https://pypi.org/project/testscenarios)
Usage
Create a PGBouncerFixture - a context manager with an extended protocol supporting access to logs etc. Customise it with database definitions, user credentials, and then when you enter the context it will create a transient pgbouncer setup in a temporary directory and run it for the duration that the context is open.
For instance:
>>> from pgbouncer import PGBouncerFixture >>> bouncer = PGBouncerFixture() >>> bouncer.databases['mydb'] = 'host=hostname dbname=foo' >>> bouncer.users['user1'] = 'credentials' >>> with bouncer: ... # Can now connect to bouncer.host port=bouncer.port user=user1
Any settings required for pgbouncer to work will be given sane defaults.
Installation
Either run setup.py in an environment with all the dependencies available, or add the working directory to your PYTHONPATH.
Development
Upstream development takes place at https://launchpad.net/python-pgbouncer.
To run the tests, run:
$ tox
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 Distribution
Built Distribution
File details
Details for the file pgbouncer-0.1.0.tar.gz
.
File metadata
- Download URL: pgbouncer-0.1.0.tar.gz
- Upload date:
- Size: 18.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf2452dedac71979e330787f3a98b40b5c2028da949c27360e298e04b4ff9aa7 |
|
MD5 | 4c0edd064e283fda681eb7f24a4b470c |
|
BLAKE2b-256 | 2cde4365b4c0cf026137a97a1a396db0b0843eca0eb77f512dbe4dde69ce2b04 |
File details
Details for the file pgbouncer-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: pgbouncer-0.1.0-py3-none-any.whl
- Upload date:
- Size: 19.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fbfff3a8116ca197cc0ba11cbd78dabd936ea5b20fd22322efdfcdf6dbb08d05 |
|
MD5 | c6dca9d4b0db20c0d83258e0f9636c20 |
|
BLAKE2b-256 | 7f9db3f9489a599d98e1c601aaae6df334ce9e3be103e5757ccd15e23e23bb82 |