pombreda / pypyodbc

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

Couldn't connect to DB2 using iSeriesAccess driver. #14

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. pypyodbc.connect("DSN=PREDEFINED_DSN")

What is the expected output? What do you see instead?
Expected to connect, 

Result:

 cnx = pypyodbc.connect("DSN=PREDEFINED_DSN")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pypyodbc.py", line 2273, in __init__
    self.connect(connectString, autocommit, ansi, timeout, unicode_results, readonly)
  File "pypyodbc.py", line 2342, in connect
    self.update_db_special_info()
  File "pypyodbc.py", line 2393, in update_db_special_info
    info_tuple = cur.getTypeInfo(sql_type)
  File "pypyodbc.py", line 1871, in getTypeInfo
    return self.fetchone()
  File "pypyodbc.py", line 1794, in fetchone
    value_list.append(buf_cvt_func(raw_value))
ValueError: invalid literal for int() with base 10: ''

What version of the product are you using? On what operating system?
Pypyodbc Version: 1.1.2
OS : Fedora 17
Python Version: 2.7
ODBC Driver : iSeriesAccess for AS400 DB2 Database.

Switched trying 64bit and 32bit driver and same error occurs 

It worked with an oracle Driver  and also with TDS for a SQL Server. 

Original issue reported on code.google.com by jah...@gmail.com on 26 Apr 2013 at 9:58

GoogleCodeExporter commented 9 years ago
Accepted. I will look into this issue during weekends.

Original comment by jiangwen...@gmail.com on 2 May 2013 at 1:34

GoogleCodeExporter commented 9 years ago
Got into the same error with SQL Server 2008R2. But i still managed to work on 
my laptop with the very same SQL Server 2008R2 and winpython 3.3.0-32bit 
installed. Checking for difference between my notebook and the server online 
ODBC configuration and found that if, at the end of ODBC connection config, i 
uncheck the box that force for regional preferences, it would work.

Original comment by iuri.que...@gmail.com on 23 May 2013 at 11:57

GoogleCodeExporter commented 9 years ago
Issue 23 has been merged into this issue.

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

GoogleCodeExporter commented 9 years ago
Hi,

Any updates on this issue?

Original comment by aleksey....@gmail.com on 6 Sep 2013 at 2:41

GoogleCodeExporter commented 9 years ago
I just update the source in GitHub , I think it can solve the connection 
problem, but not sure if date, time, datetime types can function normally with 
this version.

You can download this latest version from: 
https://github.com/jiangwen365/pypyodbc/raw/master/pypyodbc.py

Original comment by jiangwen...@gmail.com on 8 Sep 2013 at 3:25

GoogleCodeExporter commented 9 years ago
Hi, Please try version 1.2.0.

Original comment by jiangwen...@gmail.com on 21 Sep 2013 at 11:28

GoogleCodeExporter commented 9 years ago
Version 1.2.0 resolved my issue (#23); thanks for the update!

Original comment by d...@dlasley.net on 25 Sep 2013 at 5:25

GoogleCodeExporter commented 9 years ago
As an update, I can now connect to the database but am still receiving this 
error randomly while performing fetches. The new traceback is:

Traceback (most recent call last):
  File "/data01/python/wins_legacy/e2e/usage_gatherer.py", line 279, in <module>
    usage_mon.daemonize()
  File "/data01/python/wins_legacy/e2e/usage_gatherer.py", line 99, in daemonize
    method()
  File "/data01/python/wins_legacy/e2e/usage_gatherer.py", line 126, in usage_gather
    medusa_data = self.mssql.query(_med_query)
  File "/data01/python/wins_legacy/db_core/mssql.py", line 66, in query
    for row in self.cursor.fetchall():
  File "/opt/pypy-2.1/site-packages/pypyodbc-1.2.0-py2.7.egg/pypyodbc.py", line 1762, in fetchall
    row = self.fetchone()
  File "/opt/pypy-2.1/site-packages/pypyodbc-1.2.0-py2.7.egg/pypyodbc.py", line 1805, in fetchone
    value_list.append(buf_cvt_func(alloc_buffer.value))
ValueError: invalid literal for int() with base 10: ''

I noticed that you have a print statement above this line; I added some logging 
for those values (col_name, target_type, alloc_buffer.value) so maybe the log 
can provide some insight on what is happening here. This is an intermittent 
issue, I'm thinking it's due to some blank data in the database. I'll get back 
to you when I have some data. 

Original comment by d...@dlasley.net on 26 Sep 2013 at 4:21

GoogleCodeExporter commented 9 years ago
It seems that my hypothesis was correct, this is occurring on blank int/float 
cols. My fix was to add a try/except for a ValueError, appending None to the 
value_list for blank data. I have attached a patch that resolves this issue as 
I did not see a way to send a pull request.

Original comment by d...@dlasley.net on 2 Oct 2013 at 8:58

Attachments: