[egenix-users] Problem with mxodbc 3.1 and Sybase 15.5

Dale Arntson d-arntson at uchicago.edu
Thu Dec 23 14:06:21 CET 2010


Hi All,

If I execute the following function using mxodbc 3.1 against a Sybase 
15.5 database,

  def load_data(m):
     count = 0
     sql = "update uc_gbs_pick_list2 " \
           "set state = ?, viewability = ?, conditions = ?, \
           "where barcode = ?"
     for r in m.rows:
         m.db.cur.execute(sql,r)
         count += 1
         if count % 10000 == 0: m.db.con.commit()
     m.db.con.commit()

I get this error:

Traceback (most recent call last):
   File "c:\dale\dev\gbs\test\code\grin\python-49AQec.py", line 48, in main
   File "c:\dale\dev\gbs\test\code\grin\python-49AQec.py", line 166, in 
load_data
InterfaceError: ('HY010', 30102, '[Sybase][ODBC Driver]Function sequence 
error', 8148)

It updates the first row correctly, but throws an error on the second 
row. If I use: .executedirect instead of .execute in the above code, I 
get the following error on the first row:

Traceback (most recent call last):
   File "c:\dale\dev\gbs\test\code\grin\python-49Adoi.py", line 48, in main
   File "c:\dale\dev\gbs\test\code\grin\python-49Adoi.py", line 166, in 
load_data
ProgrammingError: ('42000', 257, "[Sybase][ODBC Driver][Adaptive Server 
Enterprise]Implicit conversion from datatype 'CHAR' to 'SMALLINT' is not 
allowed.  Use the CONVERT function to run this query.\n", 8396)

With .executedirect, but not with .execute, Sybase thinks that a None 
value in python used in an sql smallint column is a char, and will not 
save it as a sql NULL. This is the case whether or not I use the 
following with .executedirect:

m.db.con.bindmethod = mx.ODBC.Windows.BIND_USING_SQLTYPE or
m.db.con.bindmethod = mx.ODBC.Windows.BIND_USING_PYTHONTYPE

Any ideas or workarounds?

Thanks,

Dale Arntson





More information about the egenix-users mailing list