Mike, I made the assumption parameters would always be a dictionary:
from sqlalchemy.interfaces import ConnectionProxy class PostgresProxy(ConnectionProxy): """ Low level connection proxy to change all empty string '' to None, so that postgres and Oracle behave the same for us """ def cursor_execute(self, execute, cursor, statement, parameters, context, executemany): for param, value in parameters.items(): if value == u'': parameters[param] = None return execute(cursor, statement, parameters, context) Apparently, for some circumstances, (maybe for many to many?), parameters is a tuple? AttributeError: 'tuple' object has no attribute 'items' Can you explain when (if time, why)? How can I fix my code? Thanks! Kent On Nov 4, 11:42 am, Michael Bayer <mike...@zzzcomputing.com> wrote: > On Nov 4, 2010, at 11:16 AM, Kent wrote: > > > We are writing an application that can run on PostgreSQL or Oracle. > > Since postgres treats NULL and '' (empty string) differently, while > > Oracle treats '' as NULL, this can cause subtle behavior differences > > based on the underlying database. > > > Can you think of a way I could easily intercept all UPDATE and INSERT > > column values, and, if the value is the empty string, replace with > > None/null? > > > Thanks in advance if you can point me in the right direction. > > the current method on this is the ConnectionProxy: > > http://www.sqlalchemy.org/docs/core/interfaces.html#sqlalchemy.interf... > > > > > Kent > > > -- > > You received this message because you are subscribed to the Google Groups > > "sqlalchemy" group. > > To post to this group, send email to sqlalch...@googlegroups.com. > > To unsubscribe from this group, send email to > > sqlalchemy+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/sqlalchemy?hl=en. > > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.