Skip to content Skip to sidebar Skip to footer

Why Doesn't This Sql Script Execute?

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 us

Solution 1:

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.

Solution 2:

It looks like an invalid query problem. You're trying to run either 2 queries, or 1.5 queries in the same c.execute

You either want an insert

insert into latencies(account, replier, sender, replyemail, origemail, replydate, origdate)

Or a select

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 nulland c1.id = m1.fr and c2.id = m2.fr and m1.account = %s and m1.account = m2.account;"

Post a Comment for "Why Doesn't This Sql Script Execute?"