pythonsqldatabasepypyodbc

invalid literal for int() with base 10 pypyodbc


While I'm connecting to HFSQL database to retrieve a set of data using pypyodbc module in python with the following code

import pypyodbc
connection = pypyodbc.connect( "DSN=odbc_name" )
cursor = connection.cursor()
cursor.execute( "select * from cli" )
result = cursor.fetchall()

I get "invalid literal for int() with base 10" error, the source of this problem is the null value of some columns, any workarounds this problem besides modifying the null data in the database table.


Solution

  • the solution is to modify pypyodbc.py code located in site-packages directory, the modification is simple look for the methode dt_cvt and modify as follow:

    def dt_cvt(x):
    if py_v3:
        x = x.decode('ascii')
    if x == '': return None
    else: return x