赞
踩
我想在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()
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。