Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
GoogleCodeExporter opened this issue Mar 15, 2015 · 2 comments

Comments

@GoogleCodeExporter
Copy link

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
Copy link
Author

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
Copy link
Author

guess it has been fixed.

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

  • Changed state: Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant