Python select data return boolean true-false and DELETE value true
<p><strong>I made a program transaction.and if error,it should report position error. NOW I want to select value TRUE and DELETE value TRUE</strong></p>

<pre><code>#!/usr/bin/python
import mysql.connector

conn = mysql.connector.connect(host="lll",user="ppp",passwd="ppp",db="ppp")
cursor = conn.cursor()

cursor.execute("SELECT(case when user1 = '1' THEN 'true' ELSE 'false' END) AS IsEmtpy from dt")
print(cursor.fetchall())

try:

    if true:
        cursor.execute("DELETE FROM dt WHERE user1='1'")
        print "DELETE SUCESS"
    else:
        print "DELETE ERROR"

        conn.commit()
except Exception as e:
        conn.rollback()
conn.close()
</code></pre>

<p>result : </p>

<pre><code>File "./splinsert.py", line 13
    if true:
     ^
IndentationError: expected an indented block
</code></pre>

<p>This error is related to inconsistent indentation. Python relies on indentation to determine when "code blocks" start and stop. <a href="http://www.diveintopython.net/getting_to_know_python/indenting_code.html" rel="nofollow">Take a look at this for more details</a>.</p>

<p>Try something like this:</p>

<pre><code>#!/usr/bin/python
import mysql.connector

conn = mysql.connector.connect(host="lll",user="ppp",passwd="ppp",db="ppp")
cursor = conn.cursor()

cursor.execute("SELECT(case when user1 = '1' THEN 'true' ELSE 'false' END) AS IsEmtpy from dt")
print(cursor.fetchall())

try:
  if True:
    cursor.execute("DELETE FROM dt WHERE user1='1'")
    print "DELETE SUCESS"
  else:
    print "DELETE ERROR"
    conn.commit()

except Exception as e:
  conn.rollback()

conn.close()
</code></pre>

python mysql