Pymysql Insert Into not working

前端 未结 3 1881
感动是毒
感动是毒 2020-12-15 02:43

I\'m running this from PyDev in Eclipse...

import pymysql
conn = pymysql.connect(host=\'localhost\', port=3306, user=\'userid\', passwd=\'password\', db=\'fa         


        
相关标签:
3条回答
  • 2020-12-15 02:50

    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

    0 讨论(0)
  • 2020-12-15 02:53

    Did you commit it? conn.commit()

    0 讨论(0)
  • 2020-12-15 03:00

    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

    0 讨论(0)
提交回复
热议问题