[New-bugs-announce] [issue14720] sqlite3 microseconds

Frank Millman report at bugs.python.org
Fri May 4 08:31:06 CEST 2012


New submission from Frank Millman <frank at 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 <report at bugs.python.org>
<http://bugs.python.org/issue14720>
_______________________________________


More information about the New-bugs-announce mailing list