[SQLObject] Distinct value lookup on DateTimeCol()
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: F.A. P. <f_...@ly...> - 2007-06-13 09:22:47
|
Hi All, I have/had this class: class Birthday(sqlobject.SQLObject): day = sqlobject.IntCol() month = sqlobject.IntCol() year = sqlobject.IntCol() The choice for IntCol above DateTimeCol was simply not to complicate my very first attempt to sqlobject too much. As you see in my app I handle dates as three int's A bonus to this is that I can do queries on distinct values with: query=sqlobject.sqlbuilder.Select(Birthday.q.month,groupBy=Birthday.q.month) resultlist=Birthday._connection.queryAll(str(query)) As my app grew with options I thought date math could be better done with DateTime functions. I changed the class to: class Birthday(sqlobject.SQLObject): date = sqlobject.DateTimeCol(default=mx.DateTime.now()) Now, I have all the date calculations available but... how do I do my distinct value lookup on day, month and year? Are there solutions other than converting the int's to a DateTime object before doing the date calculations? Thanks. Frans. |