dlsyaim / pypyodbc

Automatically exported from code.google.com/p/pypyodbc
0 stars 0 forks source link

ValueError: invalid literal for int() with base 10: '' (./pypyodbc.py", line 1772, in fetchone) #23

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

Attempting to connect to MSSQL database using below code:

    cstr = 'DRIVER=FreeTDS;SERVER=%s;DATABASE=%s;PORT=%s;UID=%s;PWD=%s' % (host, db, '1433', user, passwd)
    self.mssql = pypyodbc.connect(cstr)

Returns below error/traceback:

Traceback (most recent call last):
  File "/data01/python/wins/e2e/usage_gatherer.py", line 258, in <module>
    usage_mon = usage_gatherer()
  File "/data01/python/wins/e2e/usage_gatherer.py", line 33, in __init__
    '***REMOVED User****', '***REMOVED Pass***', '*****REMOVED Table****', timeout=300)
  File "/usr/src/pypy/site-packages/wins/db_core/mssql.py", line 29, in __init__
    self.mssql = pypyodbc.connect(cstr)
  File "/usr/src/pypy/site-packages/pypyodbc-1.1.3-py2.7.egg/pypyodbc.py", line 2285, in __init__
    self.connect(connectString, autocommit, ansi, timeout, unicode_results, readonly)
  File "/usr/src/pypy/site-packages/pypyodbc-1.1.3-py2.7.egg/pypyodbc.py", line 2355, in connect
    self.update_db_special_info()
  File "/usr/src/pypy/site-packages/pypyodbc-1.1.3-py2.7.egg/pypyodbc.py", line 2405, in update_db_special_info
    info_tuple = cur.getTypeInfo(sql_type)
  File "/usr/src/pypy/site-packages/pypyodbc-1.1.3-py2.7.egg/pypyodbc.py", line 1882, in getTypeInfo
    return self.fetchone()
  File "/usr/src/pypy/site-packages/pypyodbc-1.1.3-py2.7.egg/pypyodbc.py", line 1772, in fetchone
    value_list.append(buf_cvt_func(alloc_buffer.value))
ValueError: invalid literal for int() with base 10: ''

Code works fine with pyodbc version 3.0.7. 

What version of the product are you using? On what operating system?
pypyodbc-1.1.3
Linux - RHEL 5 kernel 2.6.18-274.17.1.el5, freetds.x86_64 v 0.91-2.el5

Please provide any additional information below.

I was able to resolve the error by adding a try/except at line 1772, but I am 
uncertain as to what implications this may have.

try:
    value_list.append(buf_cvt_func(alloc_buffer.value))
except ValueError:
    #if DEBUG:print 'ValueError at fetchone() - %s %s %s' % (col_name, target_type, alloc_buffer.value, )
    pass

Original issue reported on code.google.com by d...@dlasley.net on 28 Aug 2013 at 6:55

GoogleCodeExporter commented 8 years ago

Original comment by jiangwen...@gmail.com on 3 Sep 2013 at 5:53