Open hubcin opened 6 years ago
Pony doesn't support datetime.fromtimestamp
translation yet. You can use raw SQL fragment instead:
logs = select(
(raw_sql("DAY(FROM_UNIXTIME(l.time))"), count())
for l in UserLog
if raw_sql("MONTH(FROM_UNIXTIME(l.time))") == month and l.user == user_id
)
How do I translate this statement into pony syntax(the field
time
is unixtimestamp)?select DAY(FROM_UNIXTIME(time)),count(*) from userlog group by DAY(FROM_UNIXTIME(time));
this is how I did:
logs = select( (datetime.fromtimestamp(l.time).day, count()) for l in UserLog if datetime.fromtimestamp(l.time).month == month and l.user == user_id)
and this is what I got:
TypeError: Function 'fromtimestamp' cannot be used this way: datetime.fromtimestamp(l.time)