score:133

Accepted answer

Did you commit it? conn.commit()

score:4

You can either do

  • conn.commit() before calling close

or

  • enable autocommit via conn.autocommit(True) right after creating the connection object.

Both ways have been suggested from various people at a duplication of the question that can be found here: Database does not update automatically with MySQL and Python

score:120

PyMySQL disable autocommit by default, you can add autocommit=True to connect():

conn = pymysql.connect(
    host='localhost',
    user='user',
    passwd='passwd',
    db='db',
    autocommit=True
)

or call conn.commit() after insert


Related Query

More Query from same tag