Query results from some Postgres data types are converted to native types by psycopg2
. Neither pgdb
(PostgreSQL) and cx_Oracle
seem to do this.
…so my attempt to switch pgdb
out for psycopg2cffi
is proving difficult, as there is a fair bit of code expecting strings, and I need to continue to support cx_Oracle
.
The psycopg2
docs explain how to register additional types for conversion, but I'd actually like to remove that conversion if possible and get the strings as provided by Postgres. Is that doable?
You can re-register a plain string type caster for every single PostgreSQL type (or at least for every type you expect a string for in your code): when you register a type caster for an already registered OID the new definition takes precedence. Just have a look at the source code of psycopg (both C and Python) to find the correct OIDs.
You can also compile your own version of psycopg disabling type casting. I don't have the source code here right now but probably is just a couple line changes.