Empty table in MySQL even though Python can insert data into table -


i'm new mysql , python.

i have code insert data python mysql,

conn = mysqldb.connect(host="localhost", user="root", passwd="kokoblack", db="mydb") in range(0,len(allnames)):     try:         query = "insert resumes (applicant, jobtitle, lastworkdate, lastupdate, url) values ("         query = query + "'"+allnames[i]+"'," +"'"+alltitles[i]+"',"+ "'"+alldates[i]+"'," + "'"+allupdates[i]+"'," + "'"+alllinks[i]+"')"         x = conn.cursor()         x.execute(query)         row = x.fetchall()     except:         print "error" 

it seems working fine, because "error" never appears. instead, many rows of "1l" appear in python shell. however, when go mysql, "resumes" table in "mydb" remains empty.

i have no idea wrong, not connected mysql's server when i'm viewing table in mysql? please.

(i use import mysqldb, enough?)

use commit commit changes have done

mysqldb has autocommit off default, may confusing @ first

you commit

conn.commit() 

or

conn.autocommit(true) right after connection created db 

Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -