python - 从用户输入将数据插入mysql
问题描述
如果假设有另一列名为“age”并且我在两列中插入数据,则以下语法非常有效。但在这种情况下,它显示语法错误。所以我假设这里会使用稍微不同的语法?
db=mysql.connector.connect(host="localhost",user="root",password='',database="cs")
c=db.cursor()
c.execute("create table if not exists leaderboards(idn int auto_increment primary key, name varchar(30))")
nm=str(input("enter your name"))
c.execute("insert into leaderboards(name) values(%s)",(nm))
db.commit()
c.close()
db.close()
解决方案
推荐阅读
- python - 如何使用python电报机器人将pdf文件发送回用户?
- mysql - php mysql 在 7 天内获取即将到来的生日 dd-MMM-yy
- strapi - Strapi V3.0.1 - 我的插件设置按钮在哪里?
- ios - 如何从场景委托中调用在视图控制器中下载 URL 的函数?
- javascript - 电子邮件地址验证正则表达式
- oracle - 无法创建配置文件:TNS-04414:文件错误
- amazon-web-services - AppSync 与 Glue 集成
- html - 在动态生成的组件中每行最多显示 4 个图标
- python - 使用 tkinter 按钮在海龟中打开图像时出现错误“pyimage1”不存在
- sql - 由于“未满足的依赖项”,无法在 Ubuntu 上安装 SQL Server 命令行工具