New submission from Frank Millman <fr...@chagford.com>:

sqlite3/dbapi2.py contains the following - 
    def convert_timestamp(val): 
        datepart, timepart = val.split(b" ")
        timepart_full = timepart.split(b".")
        [...] 
        if len(timepart_full) == 2: 
            microseconds = int(timepart_full[1]) 
        else: 
            microseconds = 0 

It assumes that 'timepart_full[1]' is a string containing 6 digits. 

I have a situation where the string containing 3 digits, so it gives the wrong 
result. For example, if the string is '456', this represents 456000 
microseconds, but sqlite3 returns 456 microseconds.

I think that it should right-zero-fill the string to 6 digits before converting 
to an int, like this - 

    microseconds = int('{:0<6}'.format(timepart_full[1]))

----------
components: Library (Lib)
messages: 159905
nosy: frankmillman
priority: normal
severity: normal
status: open
title: sqlite3 microseconds
type: behavior
versions: Python 3.2

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue14720>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to