#24 Fractional second support for MySQL 5.6.5

open
Andy Dustman
MySQLdb (19)
5
2012-09-19
2012-07-17
Anonymous
No

Fractional second support up to microseconds has recently been added in MySQL 5.6.4 and higher. I was hoping that MySQLdb will add support for this feature with timedelta. Currently, to bypass this issue I have modified MySQLdb/times.py and it seems to be working for my purposes.

def format_TIMEDELTA(v):

microseconds = v.microseconds
seconds = float(v.seconds) % 60
minutes = int(v.seconds / 60) % 60
hours = int(v.seconds / 3600) % 24

return '%d %d:%d:%d.%06d' % (v.days, hours, minutes, seconds, microseconds)

Although my patch seems to be working, to be more robust I expect that timedelta millisecond support might also be needed.

Discussion