File: README

package info (click to toggle)
python-pgbouncer 0.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 192 kB
  • sloc: python: 247; makefile: 7
file content (81 lines) | stat: -rw-r--r-- 2,399 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
************************************************
python-pgbouncer: Python glue to drive pgbouncer
************************************************

    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