I am trying to insert a data in MySQLdb when a condition accomplish, but never do that and jump to the except db.rollback(). which is my mistake? .Thanks
import MySQLdb
if __name__ == '__main__':
try:
db=MySQLdb.connect("localhost","root","test","objects_ingresed")
c= db.cursor()
print("success conection")
except:
print ("cant conect to server...")
if dA >= 62 and dA <= 71:
if dB >= 43 and dB <= 50:
sql = """INSERT INTO objects (cut_disc) VALUES(1)"""
try:
c.execute(sql)
db.commit()
print("data inserted")
except:
db.rollback()
print("data NO inserted")