Support,

I recently updated our MySQL database to version 5.6.5 with hopes of
using the newly added fractional second support for the Time datatype.
Using SQLalchemy version 0.6.5 to create our table definitions, I add
the fractional second percision paramater to the time type as shown in
the MySQL documentation:

meta_timings = Table('meta_timings', metadata,
                   ...
                    Column('elapsed', Time(2), nullable=False),
                  ...)

However, when I build the database with these new table definitions,
sqlalchemy seems to ignore the new time parameters and creates the
table using the default time command without fractional second
precision. The resulting table definition is:

CREATE TABLE `meta_timings` (
...
 `elapsed` time NOT NULL,
...
) ;

When I attempt to bypass this problem by manually creating this table
definition by using `session.execute(''' table definition '''), the
MySQL database renders the time in the correct format with two
fractional seconds places after the seconds place (00:00:00.00 instead
of 00:00:00). This is a step closer, however, when I use timedelta to
insert the data, everything except the fractional seconds is parsed
and put into the time datatype correctly. The result is that every
time has .00 fractional seconds (example xx:xx:xx.00).

Here is how I am parsing our data using timedelta:

# Match time values
   time_re = re.match('(\d{1,2}):(\d{1,2})\.(\d{1,2})', v)
   if time_re:
     minutes, seconds, milliseconds = [int(x) for x in
time_re.groups()]
     td = timedelta(minutes=minutes, seconds=seconds,
milliseconds=milliseconds)
     return td

Does sqlalchemy support this type of operation?

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to