Loprz / pypyodbc

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

TIMESTAMP columns in SAP HANA cause ValueError: microsecond must be in 0.999999 #36

Open GoogleCodeExporter opened 8 years ago

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

1. Connect to a SAP HANA database and select columns which include a timestamp

e.g. This example should work on any HANA instance

cur.execute('select END_TIME from M_CONNECTIONS')
cur.fetchall()

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pypyodbc.py", line 1795, in fetchall
    row = self.fetchone()
  File "pypyodbc.py", line 1844, in fetchone
    value_list.append(buf_cvt_func(alloc_buffer.value))
  File "pypyodbc.py", line 568, in dttm_cvt
    if x == '': return None
ValueError: microsecond must be in 0..999999

The END_TIME column is HANA type TIMESTAMP.  Below is the pdb output:

>>> cur.fetchall()
> pypyodbc.py(566)dttm_cvt()
-> if py_v3:
(Pdb) x
'2014-02-25 14:57:08.487000000'

What is the expected output? What do you see instead?

Expected output is no Traceback.

What version of the product are you using? On what operating system?

pypyodbc version: 1.2.1
python version: 2.7.2
OS version: Linux localhost.localdomain 2.6.32-279.19.1.el6.x86_64 #1 SMP Wed 
Dec 19 07:05:20 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

Please provide any additional information below.

NOTE: I fixed this locally, by changing the following line in dttm_cvt(x) from:

else: return 
datetime.datetime(int(x[0:4]),int(x[5:7]),int(x[8:10]),int(x[10:13]),int(x[14:16
]),int(x[17:19]),int(x[20:].ljust(6,'0')))

to:

else: return 
datetime.datetime(int(x[0:4]),int(x[5:7]),int(x[8:10]),int(x[10:13]),int(x[14:16
]),int(x[17:19]),int(x[20:25].ljust(6,'0')))

Original issue reported on code.google.com by iwi...@zenossinc.com on 25 Feb 2014 at 11:48

GoogleCodeExporter commented 8 years ago
Hi, I have add some coding fix it. Can you try the new version 1.3.1 on PYPI?

Original comment by jiangwen...@gmail.com on 11 Mar 2014 at 2:15

GoogleCodeExporter commented 8 years ago
guess it has been fixed.

Original comment by jiangwen...@gmail.com on 27 May 2014 at 9:57