mysql.connector.errors.ProgrammingError:1054(42S22):“字段列表”中的未知列“代码”

2024-06-24 13:16:35 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经检查了其他代码和解决方案,但我就是找不到解决方案

CODE

table = "create table salesperson (code int, name varchar(35), salary int, itcode varchar(4))"
cursor.execute(table)

code = int(input('Enter the code:'))
name = input('Enter the name:')
salary = int(input('Enter the salary:'))
itcode = input('Enter the itcode:')

command = "insert into account(code,name,salary,itcode) values(%s,%s,%s,%s)"
values = (code, name, salary, itcode)
cursor.execute(command, values)
mycon.commit()
print('record(s) inserted')

ERROR


Tags: thenameinputexecutetablecode解决方案cursor
1条回答
网友
1楼 · 发布于 2024-06-24 13:16:35

我建议您将表实体的创建分离到它自己的函数中。然后使用MySQL Workbench或其他工具验证您的模式是否正确创建

看起来您正在创建一个表salesperson,但正在插入到account中?看看这个

相关问题 更多 >