| | 81 | |
| | 82 | Right now I'm doing: |
| | 83 | |
| | 84 | {{{#!python |
| | 85 | with connection.cursor() as c: |
| | 86 | c.execute('SELECT q.day, q.temperature FROM (%s) AS q WHERE q.temperature IS DISTINCT FROM q.prev_temp' % str(Weather.objects.annotate(prev_temp=Window(expression=Lead('temperature'), order_by=F('day').desc())).order_by('-day').values('day','temperature', 'prev_temp').query)) |
| | 87 | result = c.fetchall() |
| | 88 | }}} |
| | 89 | |
| | 90 | Important to note that I couldn't use the str(queryset.query) as parameter to the c.execute. I had to do a python replace. |
| | 91 | I.e, had to use ('...%s...' % parameter) instead of c.execute ('...%s...', [parameter]) |