| Paste number 42367: | get_years (remember this? |
| Pasted by: | tanuki |
| When: | 2 years, 4 weeks ago |
| Share: | Tweet this! | http://paste.lisp.org/+WOV |
| Channel: | #pylons |
| Paste contents: |
def get_years(self):
"Get a list of years for which the user has records."
# Create query:
# SELECT DISTINCT EXTRACT('year' FROM day)
# FROM days
# WHERE username = <username>;
sel = sa.sql.select([sa.sql.extract('year', days_table.c.day).distinct()], whereclause=days_table.c.username==self.username)
# Execute the query and get all results
years = session_context.current.bind_to.execute(sel).fetchall()
# Strip the superfluous tuples
return [int(y[0]) for y in years]This paste has no annotations.