time calculations

Steve Holden sholden at holdenweb.com
Wed Sep 13 21:27:36 CEST 2000

Pop Tufty wrote:
> I am looking for a package that will allow me to
> perform calculations on time variables.  I am
> accessing a MySQL database with MySQL
> timestamps for events, and I want to know
> how many hours ago these events happened.
> I have something such as:
> import MySQL
> DBH = MySQL.connect();
> DBH.selectdb('mydb');
> STH = DBH.query("select Time from tablea")
> for row in STH.fetchrows():
>     event_time = row[0]
>     ..
>     .. and now I want to compare this with the current
>     .. time to see how old this event is.
> Does anyone have any suggestions on how to go about
> doing this - I would rather not have to write a time string
> parser...
> thanks

The mxDateTime module (available form the starship) can do just
about anything you might want with dates.  You may also wish to consider
using the mxODBC package (also by Marc-Andre Lemburg) to access the
database -- I think it has MySQL drivers.

Helping people meet their information needs with training and technology.
703 967 0887      sholden at bellatlantic.net      http://www.holdenweb.com/

More information about the Python-list mailing list