Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support a pure-Python PostgreSQL driver #85

Closed
jamadden opened this issue Jun 28, 2016 · 0 comments · Fixed by #98
Closed

Support a pure-Python PostgreSQL driver #85

jamadden opened this issue Jun 28, 2016 · 0 comments · Fixed by #98

Comments

@jamadden
Copy link
Member

This will be necessary for gevent support. Both psycopg2 and psycopg2cffi call through to the native libpq, which manages its own native sockets and can't be portably monkey patched.

It looks like the best supported is probably pg8000. If there's a better one, please let me know!

@jamadden jamadden added this to the 2.0.0b2 milestone Jul 1, 2016
@jamadden jamadden self-assigned this Jul 1, 2016
jamadden added a commit that referenced this issue Jul 1, 2016
The major difference from psycopg2/cffi is that it doesn't have native
lobject support. This is easily worked around, but this draft is not
complete because it doesn't support chunks. Some refactoring will be
required to elegantly handle this.

Two minor differences:

- It doesn't support multiple statements in a single `cursor.execute()`
  call. Apparently it turns all statements into prepared statements,
  because the error is from the server. Easily worked around and
  unlikely to be a perfomance difference.
- It handles transaction isolation levels like most other drivers, in
  SQL. This could be handled more elegantly too.

One thing: The server spits out lots of "WARNING: not in a transaction".
If I enable statement logging, I see every `commit` immediately followed
by a `rollback`, which generates the warning. I'm not sure if that's
just us, or something the driver is doing differently (e.g, maybe
psycopg2/cffi always follows `commit` with `begin`? and then when we try
to `rollback` we're already in a transaction?). Annoying but harmless.
Still, would like to figure it out though.

Testing this pure-python driver on Python 3 also revealed a lot of
connection leaks, many of which I've fixed, but there are probably more.
This should be a win for PyPy. See also zopefoundation/ZODB#78.

The testing matrix is expanded to test the pure-python drivers on
CPython too and to test pg8000. (Travis will be the first time I run
psycopg2 tests; hope I didn't break anything!)

Fixes #85.
@jamadden jamadden mentioned this issue Jul 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant