mysql - Python MySQLdb: table does not get deleted immediately -



mysql - Python MySQLdb: table does not get deleted immediately -

in code seek delete table database (delete_table function). right after this, check if table has been deleted or not (check_table_from_db function). when this, table gets deleted check_table_from_db function shows not. when process in 2 different runs (two different programs). result correct. next code check_table_from_db:

def check_table_from_db(table_name): import mysqldb mdb try: exists = false con = mdb.connect('localhost', 'user', '123', 'test') cur = con.cursor() s = "show tables '%s'" % (table_name) cur.execute(s) exists = (cur.rowcount > 0) except mdb.error, e: print "error %d: %s" % (e.args[0],e.args[1]) sys.exit(1) finally: if con: cur.close() con.close() homecoming exists

edit: since has been requested post delete_table function, need explain general purpose. delete_table function mimics sql injection attack. if attack successful, table gets deleted database (i check through check_table_from_db). injects code in 1 of fields in website. such code delete table is:

attack_script = "');drop table test2;" _resp = utilities.submit_form(utilities.get_absolute_url(fd.get('action'), main_url), {'uname':'test', 'password':'test', 'cpassword':'test', 'fname':'', 'lname':'', 'age':'', 'major':'', 'university':attack_script}, method=fd.get('method'))

through submit_form function, populate form in website , submit. 1 time submitted, check if table deleted or not.

you forgot commit:

con.commit()

python mysql mysql-python

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -