I'm using Python 2.7 together with Peewee. At this moment, I need to use Peewee to execute the following SQL query:
select
a,
b,
substring(c, 1, 3) as alias1,
count(substring(c, 1, 3)) as alias2
from Table
where <some where condition, not relevant here>
group by a, alias1
My first problem here is how to perform a substring with Peewee. I have searched the documentation and, so far, no lucky.
So, the basic question is: How do I perform a substring
SQL function using Peewee? It would also be very nice if someone can give me some directions of how to perform the entire query above with Peewee.