views:

42

answers:

1

I'm starting some new projects and want to know if pg8000 is considered a good choice for a production project?

Obviously Python and PostgreSQL are mature products, but I'm concerned about pg8000 both when it comes to maturity and performance. Will my DB access suffer or will it be acceptable?

So, please take some latitude in responding to my question. Is pg8000 ready? Will I have problems using the Python DBAPI 2.0 spec for complete access when writing a db centric program?

I know questions like this get asked all the time, but I did look and could not find anything current relating to pg8000. And obviously any answer beyond a few months would not be current considering the releases that have been committed on the related technologies.

A: 

I think your should try to make your program driver "independent". It should work with any PostgreSQL DBAPI 2.0 driver. The only difference will be at import section and at establishing a db connection. This can look like:

use_pgdb = 0
try:
    import pgdb
    use_pgdb = 1
except:
    try:
        import psycopg2
    except:
        raise exceptions.ImportError('No PostgreSQL library, install psycopg2 or PyGres!')
if use_pgdb:
    _CONN = pgdb.connect(connect_string)
else:
    _CONN = psycopg2.connect(dsn)

Add to this "chain" of drivers pg8000 and simply try it. If all drivers will work and performance will be good then leave those drivers. If one of the drivers will not work, or will have poor performance then comment it in your code and disable it. For more than 2 drivers I would change code from example and create some kind of dictionary with driver and connect function.

Michał Niklas
@Michal Niklas Thank-you for responding. I should have made it more clear I'm using DBAPI 2.0. I'm looking at pg8000 vs. other more popular drivers because pg8000 is working with Python 3x. Psycopg2 and PyGreSQL are not ported to Python 3x AFIAK. More to the point. I didn't find anything but pg8000 that seems ready for Python 3x and DBAPI 2.0. DBAPI: http://www.python.org/dev/peps/pep-0249/ pg8000: http://pybrary.net/pg8000/#python-3 Psycopg2: http://www.stickpeople.com/projects/python/win-psycopg/ PyGreSQL: http://www.pygresql.org/readme.html#where-to-get
a2j