在我的sql连接器python中创建表的错误

0 人关注

mysql.connector.errors.ProgrammingError。1064 (42000):你的SQL语法有错误;请查看与你的MySQL服务器版本相对应的手册,了解在第1行'int primary key, name varchar(100), salary int, doj date)'附近应使用的正确语法。

import mysql.connector as mysql
con=mysql.connect(host='localhost',user='root',password='mysqltables',database='school')
cur=con.cursor()
table='INSERT INTO pyStudent(id int primary key, name varchar(100), salary int, doj date)'
cur.execute(table)
for i in range (1,2):
    inpt_id=int(input('Enter employee id',i,'= ' ))
    inpt_name=input('Enter employee name',i,'= ' )
    inpt_sal=int(input('Enter employee salary',i,'= ' ))
    inpt_doj=input('Enter employee joining date',i,'= ' )
    sql = "INSERT INTO pyStudent (id, name, salary, doj) VALUES (%s, %s,%s, %s,%s, %s)"
    val = (inpt_id,inpt_name,inpt_sal,inpt_doj)
    cur.execute(sql, val)
showw='select * from pyStudent'
cur.execute(showw)
temp=cursor.fetchall()
for row in temp:
    print (row)
cur.execute('commit')