Advantages
Why use pg8000?
- No external dependencies other than Python’s standard library.
- Pretty cool to hack on, since it is 100% Python with no C involved.
- Being entirely written in Python means it should work with Jython, PyPy, or IronPython without too much difficulty.
- libpq reads the entire result set into memory immediately following a query. pg8000 uses cursors to read chunks of rows into memory, attempting to find a balance between speed and memory usage for large datasets. You could accomplish this yourself using libpq by declaring cursors and then executing them to read rows, but this has two disadvantages:
- You have to do it yourself.
- You have to know when your query returns rows, because you can’t DECLARE CURSOR on an INSERT, UPDATE, DELETE, CREATE, ALTER, ect.
- pg8000 offers objects to represent prepared statements. This makes them easy to use, which should increase their usage and improve your application’s performance.
- It has some pretty nice documentation, I think.
Disadvantages
Nothing is perfect, right? Here are some disadvantages to using pg8000 over other PostgreSQL libraries:
- It’s pretty new. This means there are likely bugs that haven’t been found yet. It will mature over the next couple weeks with some community feedback and some internal testing.
- It doesn’t support every PostgreSQL type, or even the majority of them. Notably lacking is the interval data type. This will just be a matter of time as well, and hopefully some user patches to add more functions.
- pg8000 does not automatically know the location of a UNIX domain socket to connect to. Normally it seems this information is built into libpq when it is compiled with the PostgreSQL server.
- It only supports authentication to the PG backend via trust, ident, or md5 hashed password.
Addressed Disadvantages
- pg8000 did not support SSL (ticket #16).
- pg8000 did not support the DB-API interface until v1.02.
- pg8000 was not thread-safe until changeset:821, released in pg8000 v1.01.
- pg8000 did not support UNIX domain sockets until changeset:821, released in pg8000 v1.01.
