[Tutor] trouble with dates and python and databases
Christopher Spears
cspears2002 at yahoo.com
Fri Mar 12 05:09:02 CET 2010
I'm trying to write a script that calculates the rate of disk usage. I think the best way to accomplish this task is to write a script that will monitor a server's capacity and how much space is being used on a daily basis and store the information in a SQLite database. Then the program can retrieve the necessary information from the database to compute the rate.
Server 1
3/11/10 10 GB Used/50 GB Capacity
3/12/10 15 GB Used/50 GB Capacity
3/13/10 17 GB Used/50 GB Capacity
Rate of usage = 7 GB / 3 days = 2.3 GB per day
Eventually, I want the script to issue a warning if the server is in danger of becoming full in a certain number of days.
My problem is I'm not sure how to store and retrieve the dates. I assume the best way to record the date is to use datetime.date.
>>> import datetime
>>> datetime.date.today()
datetime.date(2010, 3, 11)
How could I pass the datetime object into the database?
Any advice would be appreciated!
More information about the Tutor
mailing list