dimanche 28 décembre 2014

sqlite query with strftime always returns None

I have the following function:



for i in range(1,13):
q_totes_1="""SELECT sum(kaxia) FROM es_data WHERE strftime('%%m',es_date)='%s' AND es_orig=1"""%(str(i))
self.cur.execute(q_totes_1)
m_totes_1=self.cur.fetchone()[0]
print q_totes_1
if m_totes_1 is None:
m_totes_1=0.0


It always returns None while I know that I should have another result. From the print q_totes_1 I get the query which I execute straightly on sqlite and I get the desired result. All the imports are correct as I already have used them successfully in other functions of the same class.


I tried running a similar query without the strftime('%%m',es_date)='%s' portion and it run correctly.


Can somebody give me a hint of what I'm missing?


Aucun commentaire:

Enregistrer un commentaire