Working time series using SQL queries generated in Python.