masroore / pg_simple

A simple wrapper over psycopg2 with support for common SQL functions and connection pooling

Home Page:https://pypi.python.org/pypi/pg_simple

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Any way to support multi database connections?

c19 opened this issue · comments

commented

It seems that only one database can be specified.
I need to connect to three different database in one program.

pool1 = pg_simple.config_pool(dsn='dbname=first_db user=username ...')
pool2 = pg_simple.config_pool(dsn='dbname=second_db user=username ...')

with pg_simple.PgSimple(pool1) as db1:
    db1.insert('table1', data={'column': 123})
    db1.commit()

with pg_simple.PgSimple(pool2) as db2:
    rows = db2.fetchall('table2')