Comment 2 for bug 1273921

Revision history for this message
Sandip Bhattacharya (sandipb) wrote :

Since all we are doing here is converting Oracle specific data to a standardized jdbc data, we would normally just need:

def your_ora_todatetime(java_val):
    java_val = java_val.toJdbc()
    return _todatetime(java_val)

Would it make sense to instead give users an option to "filter" driver specific data to jdbc standard?

e.g.
conn = connect('oracle.jdbc.OracleDriver', ['jdbc:oracle:thin:@//foo:1521/bar'],
                              jdbc_converters=dict(TIMESTAMP=lambda x: x.toJdbc()))

If fact, since we know this driver specific issue, we may have this map in the dbapi2 module itself:
     jdbc_converters = {
                                         'oracle.jdbc.OracleDriver': {
                                                               'TIMESTAMP': lambda x: x.toJdbc()
                                                            }
                                       }

Your converter logic can then check if there is an additional jdbc converter required for a specific driver before doing the usual processing.