Hi I have the following python:
c = conn.cursor()
#get the account id for the specific user
actidSQL = "select id from accounts where user_id = (select id from auth_user where username = '%s');" % user
c.execute(actidSQL)
actid = c.fetchone()[0]
print actid
#fill the latencies table - currently not firing, not sure why?
latencies_sql = "insert into latencies(account, replier, sender, replyemail, origemail, replydate, origdate) select m1.account, c1.id as replier, c2.id as sender, m1.id as replyemail, m2.id as origemail, m1.date as replydate, m2.date as origdate from contacts c1, contacts c2, emails m1, emails m2 where m1.id > m2.id and m1.reply = m2.mid and m1.reply is not null and c1.id = m1.fr and c2.id = m2.fr and m1.account = %s and m1.account = m2.account;" % (actid)
print latencies_sql
c.execute(latencies_sql)
The first sql executes but the second doesn’t. Is there a reason why?
What do you mean with “The first sql executes but the second doesn’t.”? You get an error? Or is there no data in the DB? I assume that there is no data in the database and you are using MySQL. This is because you don’t commit your changes. A
conn.commit()at the end of your script should help.