I have a problem with the following query; This, itself, works fine, but it groups by second, I want to truncate seconds and group by minute. I have experimented with date_trunc, extract and so on, but I haven't had any luck. When the engine was sqlite, extract('minute') worked fine, but not with postgresql.
Anyone that can point me in the right direction?
PostgreSQL version: PostgreSQL 8.1.23 on x86_64-redhat-linux-gnu
Column('id', Integer, primary_key=True),
Column('date', TIMESTAMP),
Column('src', String),
Column('dst', String),
Column('len', String),
Column('sport', String),
Column('dport', String),
Column('method', String),
Column('host', String),
Column('useragent', String),
Column('statusline', String),
Column('location', String),
Column('server', String),
Column('load', String),
now = datetime.datetime.now()
DD = now - datetime.timedelta(minutes=60)
DD = DD.strftime('%Y-%m-%d %H:%M:%S')
query = session.query(HTTP.date,HTTP.statusline, func.count(HTTP.statusline).
label('count')).filter(HTTP.statusline.like('%'+status+'%'), HTTP.date>=(DD)).group_by(HTTP.date, HTTP.statusline).order_by(asc(HTTP.date)).all()
Please note that you can always comment on your own posts, and any part of your questions. However, commenting on other people's posts is a privilege.More info here.