[Tutor] Re: Dates and databases, and blobs and Python.
Lee Harr
missive at hotmail.com
Sun Mar 27 00:57:08 CET 2005
>Just a quick query. I want to store dates and work with them in my
>SQLite database.
>There's no specific need for any calculations to done on one side or
>another (i.e. it's a single user database).
>
>I googled how to work with dates in SQL, and I got one like this -
>
>SELECT * FROM totp
>WHERE wk BETWEEN '1980/05/20'
> AND '1980/05/26'
>
>as an example of finding a range for a date. I'm not too sure about
>how SQL works with dates (and times for that matter), so I'm tempted
>to stick to what I know and just store dates/times as strings in the
>db, and then use them to create datetime objects when needed.
>
I have not worked much with sqlite, but from this page:
http://www.sqlite.org/datatype3.html
it appears that sqlite does not have a date datatype.
>>>>theDateTime = datetime.datetime(intD[0], intD[1], intD[2], intT[0],
>>>>intT[1])
>
>Although working with dates like that doesn't seem that flash either.
Well... create a wrapper function to clean it up, right?
>Alternatively, I was thinking of storing the actual datetime object in
>the database (this is a blob I believe?), and that's a whole new
>kettle of fish.
>
I have heard a lot of really good things about SQLObject:
http://sqlobject.org/
However, that requires a more full-featured database, like postgresql.
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
More information about the Tutor
mailing list