当前位置:   article > 正文

mysql python连接器_Mysql连接器Python语法

"pythonsyntax to use near \\'select true; --\"\\'\\"

我想在tkinter接口中运行create函数,但它给出了以下错误:1064 (42000): You have an error in your SQL syntax; check the manual

that corresponds to your MySQL server version for the right syntax to

use near ''' (id INT NOT NULL AUTO_INCREMENT,cash INT,dt DATE, PRIMARY

KEY(id))' at line 1

这是密码。我尝试了很多想法,但什么也没有。。。在from mysql.connector import MySQLConnection, Error

from tkinter import *

DB_HOST = 'localhost'

DB_USER = 'root'

DB_PASS = 'mysql123'

DB_NAME = 'Savings'

def create(Name):

try:

connection = MySQLConnection(host=DB_HOST,user=DB_USER,password=DB_PASS,database=DB_NAME)

cursor = connection.cursor()

tabla = Name.get()

cursor.execute("CREATE TABLE %s (id INT NOT NULL AUTO_INCREMENT,cash INT,dt DATE, PRIMARY KEY(id))", (tabla,))

print("Hecho!")

except Error as e:

print(e)

finally:

connection.commit()

cursor.close()

connection.close()

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/509003
推荐阅读
相关标签
  

闽ICP备14008679号