- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这是我的一个查询,它在包含示例值的 MySQL 工作台中运行良好,并且如果我手动在代码中插入值,则运行良好,但当我使用这些值作为参数时,该查询会失败。有什么想法吗?
Python 代码:
print player
cur.execute("""
INSERT INTO scoredata
(gameid, playerid, starter, pos, min, fgm, fga, tpm, tpa, ftm, fta, oreb, reb, ast, stl, blk, tos, pf, pts)
VALUES
(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s);
"""), (player[0],
int(player[20]),
int(player[19]),
player[3],
int(player[4]),
int(player[5]),
int(player[6]),
int(player[7]),
int(player[8]),
int(player[9]),
int(player[10]),
int(player[11]),
int(player[12]),
int(player[13]),
int(player[14]),
int(player[15]),
int(player[16]),
int(player[17]),
int(player[18]) )
db.commit()
错误消息:
['330060130', 103, 'Roy Devyn Marble', 'G-F', '28', '4', '9', '3', '6', '3', '3', '0', '2', '1', '0', '0', '0', '1', '14', 1, 1391]
Traceback (most recent call last):
File "C:\Users\jcaine\workspace\BasketballStats\src\BasketballStats\basketballstats.py", line 350, in <module>
insert_game_data('20130106', '20130106')
File "C:\Users\jcaine\workspace\BasketballStats\src\BasketballStats\basketballstats.py", line 284, in insert_game_data
"""), (player[0], int(player[20]), int(player[19]), player[3], int(player[4]), int(player[5]), int(player[6]), int(player[7]), int(player[8]), int(player[9]), int(player[10]), int(player[11]), int(player[12]), int(player[13]), int(player[14]), int(player[15]), int(player[16]), int(player[17]), int(player[18]) )
File "c:\users\jcaine\appdata\local\temp\easy_install-7_fysp\MySQL_python-1.2.3-py2.7-win32.egg.tmp\MySQLdb\cursors.py", line 174, in execute
File "c:\users\jcaine\appdata\local\temp\easy_install-7_fysp\MySQL_python-1.2.3-py2.7-win32.egg.tmp\MySQLdb\connections.py", line 36, in defaulterrorhandler
_mysql_exceptions.ProgrammingError: (1064, "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 '%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)' at line 4")
MySQL Scoredata 表列:
gameid varchar
playerid int
starter int
pos varchar
min int
fgm int
fga int
tpm int
tpa int
ftm int
fta int
oreb int
reb int
ast int
stl int
blk int
tos int
pf int
pts int
在 Workbench 中运行良好的 MySQL 代码:
INSERT INTO scoredata (gameid, playerid, starter, pos, min, fgm, fga, tpm,
tpa, ftm, fta, oreb, reb, ast, stl, blk, tos, pf, pts)
VALUES ('3300601300', 1391, 1, 'G-F', 28, 4, 9, 3, 6, 3, 3, 0, 2, 1, 0, 0, 0, 1, 14)
最佳答案
您没有将数据传递给执行调用。请注意示例中的右大括号。
cur.execute("""
INSERT INTO scoredata
(gameid, playerid, starter, pos, min, fgm, fga, tpm, tpa, ftm, fta, oreb, reb, ast, stl, blk, tos, pf, pts)
VALUES
(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s);
""")//*Remove me*
, (player[0],
int(player[20]),
int(player[19]),
player[3],
int(player[4]),
int(player[5]),
int(player[6]),
int(player[7]),
int(player[8]),
int(player[9]),
int(player[10]),
int(player[11]),
int(player[12]),
int(player[13]),
int(player[14]),
int(player[15]),
int(player[16]),
int(player[17]),
int(player[18]) )
db.commit()
关于python - MySQL INSERT 在 Python 中失败,但在 MySQL Workbench 中工作正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18406994/
我想不通这个。我无法使用 MySQL Workbench 连接到服务器,我尝试了任何一种连接方法。我得到的错误信息是 Failed to Connect to MySQL at AT 127.0.0.
我尝试使用 mysql workbench for windows,但在上下文菜单duplicate table 中找不到命令。 谁能说出这个命令在哪里? 最佳答案 在 SQL IDE 中没有复制表的
任何人都可以发布解释性行如何重命名 Mysql Workbench 6.2 中的选项卡吗? 根据手册,该功能在那里 => http://dev.mysql.com/doc/workbench/en/w
我的 MySQL Workbench 有一个严重问题:我实际上无法编辑“列”选项卡,因为它是灰色的。 我试图为新创建的图表和现有图表编辑表格的列,但没有运气。 WB 的最新版本是否存在错误,或者我是否
我有一个在 MySQL Workbench 中设计的架构。我为表格添加了描述,并为列和 View 添加了注释。 我创建了一个图表,我想查看图表中的注释和描述。有没有办法做到这一点?我注意到工具提示显示
定义关系时,如何使Workbench显示表之间的连接线? 最佳答案 在EER模型中编辑表时,将有一个名为Foreign Keys的选项卡,可用于定义好...外键。这些外键将在图中可见。 您可以通过双击
有没有办法在 MySQL Workbench 的结果网格中添加一些行号? 例如。 (红色数字): 我不想更改 SQL 查询,我知道我可以使用 tricks喜欢 SELECT @n := @n + 1
我在我的图表的图表属性中使用了 2 页。 但是,我想在一张 dinA4 纸上打印整个图表。这可能吗? 最佳答案 文件 > 页面设置...设置最适合您的图表的页面。 文件 > 打印到文件... 不仅仅是
尝试打开 mwb 模型文件时出现以下错误 error unserializing grt data string to long 我的文件为 217 KB,我使用的是 6.3.4.0 版本 828(适
我正在使用 CentOS 6.4,并且做到了 sudo yum install mysql-workbench-community.x86_64 安装了 MySQL Workbench 6.1 版 当
我最近将开发机器升级为使用MySQL Workbench 6.1。我试图使用工作台和“选择行...”在表中输入一些数据,当我单击“应用”按钮以插入数据时,工作台报告发生了错误(请参见下图),但是没有告
我知道如何从工作台导出文件并上传到 Excel 进行分析。最近我有一台带工作台的 Windows 计算机,我可以从查询中选择所有结果,然后粘贴到电子表格中。我最近转移到 Mac 并下载了 MySQL
如何使用 MySQL Workbench 工具创建多态关系?我希望能够处理类似 Rails 给我的东西: class Example < ActiveRecord::Base belongs_to
在 MySQL Workbench 中,双击表对象会将表名粘贴到当前关注的查询文件中。 可以改变吗?我想在双击时看到表格内容。 或者至少,禁用当前行为。 那可能吗?如何? 谢谢。 最佳答案 您不能,但
在 mySQL Workbench 中,当在表上使用“复制到剪贴板”时,创建的 sql 语句包含将列名、表名等换行的反引号 (`)。有办法避免吗? 最佳答案 一旦您选择了所需的行,您需要右键单击并选择
目前,每次我想通过 MySQL Workbench 转储数据库时,它都会默认显示此标准路径: /home/me/dumps/Dump20110810 # The date alters. 因为我已经将
如何更改 MySQL Workbench 界面字体大小? 请注意:界面,而不是编辑器字体。 Windows 8.1 上的工作台 6.3 最佳答案 那是不可能的。有些地方使用系统字体大小(尤其是标准控件
默认情况下,自动补全为小写。有什么办法让它变成大写吗? 最佳答案 我提交了bug report : Description: The autocompletion uses lowercase ins
我在 MySQL Workbench 中创建了一个 DB 模型和 EER 图。我正在使用工作台脚本功能编写一个脚本来生成代码,以便在数据库导出并在 MySQL 服务器上创建后使用该数据库。 当我遍历表
我刚得到一个新项目,它需要与一个数据库一起工作,没人知道它的结构。它在Mysql DB上,所以我尝试使用mySQL Workbench通过使用许多其他人推荐的逆向工程功能从这个DB导出EER图 我确实
我是一名优秀的程序员,十分优秀!