如果我用python运行查询,它将返回一个语法错误。在
但是,如果我用navicat运行这个,它就可以了。在
为什么它不在python中运行?在
sql查询
INSERT INTO
solarsystem
(
solarsystemName,
solarsystemPositionX,
solarsystemPositionY,
solarsystemSectorId,
solarsystemAngle
)
VALUES
('Lima [698/562]',698,562,13,171);
SELECT LAST_INSERT_ID();
错误
1064, u"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 'SELECT LAST_INSERT_ID()'
[编辑]
创建.py
^{pr2}$更新
如果我尝试将INSERT
作为单个查询,这就可以了。在
但是,SELECT LAST_INSERT_ID();
没有起作用。它返回:
TypeError: not all arguments converted during string formatting
在连接上执行此操作以获取插入到游标对象上的最后一行ID
你可以用
或者如果你有光标:
^{pr2}$编辑
对于sqlalchemy,您可以使用:
你的身份证在
last_id
但是必须从sql查询中删除
SELECT LAST_INSERT_ID();
相关问题 更多 >
编程相关推荐