File: ex_07_date_relative.py

package info (click to toggle)
sqlkit 0.9.5-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 8,184 kB
  • sloc: python: 17,477; sql: 166; makefile: 95; xml: 23; sh: 11
file content (25 lines) | stat: -rw-r--r-- 631 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
"""base/filters: relative dates

A filter may be expressed as a relative interval from now.
read complete documentation on here:
  http://docs.argolinux.org/sqlkit/sqlkit/filters.html

But for now you can play with symbolic math: y for year, m for month,
d for day, w for week.

the '>' sign sets a period.

This allows to express dates in a very natural way. particularly when you need
to save queries

"""

t = SqlTable('movie', dbproxy=db, geom=(600, 400))
t.add_filter(date_release__gte='y-1 +2m')
t.reload()

t2 = SqlTable('movie', dbproxy=db,  geom=(600,400))
t2.add_filter(date_release__gte='y-5 > y-2')
t2.reload()

t = t2