将python中的值保存到mysql db

时间:2018-06-14 06:07:54

标签: python mysql database

Hey Guys在尝试将值保存到mysql db时遇到错误。这是我的代码。

db = MySQLdb.connect(host="localhost", user="root", passwd="developer", db="recaptcha")

cur.execute("SELECT * FROM `captcha_response`")

cur.execute("INSERT into captcha_response(id, response) values (%s, %s)" % (0, token))

这是我的错误。

raise errorclass, errorvalue
OperationalError: (1054, "Unknown column '03ACgFB9t_ZvEFuHACU8HebuQ6zrFe_k0n9SLsoJU5GC3tm' in 'field list'")

这是mysql db info。

    my database name is: "recaptcha"
    my table name is: "captcha_response"
    Example of where the items get stored
                          id                           response

Edit Copy Delete          1                            03ACgFB9uxJ...                                       

Here is the image of my table

1 个答案:

答案 0 :(得分:0)

这是答案的家伙!谢谢大家的帮助!

db = MySQLdb.connect(host="localhost", user="root", passwd="developer", db="recaptcha")

cur.execute("SELECT * FROM `captcha_response`")

cur.execute("INSERT into captcha_response(id, response) values (%s, %s)", (0, token))

db.commit()