我有一个将记录插入表中的过程。该过程由python脚本调用。作为该过程的一部分,选择了最后插入的记录。我想要python脚本打印最后一条记录。 本质上,回显刚刚插入的记录。
记录已正确插入,但无法将其返回给python。
以下是似乎失败的过程位:
create procedure customer.createSite(
IN siteID VARCHAR(100),
IN siteName VARCHAR(100),
IN siteAddress1 VARCHAR(100),
IN siteAddress2 VARCHAR(100),
IN siteCity VARCHAR(100),
IN siteState VARCHAR(2),
IN siteZipCode INT(5),
IN siteCountryCode VARCHAR(3),
IN siteCode1 VARCHAR(3),
IN phoneNumber VARCHAR(12),
IN website VARCHAR(100)
)
begin
INSERT INTO `Site` (siteID, siteName, siteAddress1, siteAddress2, siteCity, siteState, siteZipCode, siteCountryCode, siteCode1, phoneNumber, website)
VALUES (siteID, siteName, siteAddress1, siteAddress2, siteCity, siteState, siteZipCode, siteCountryCode, siteCode1, phoneNumber, website);
SET @lastRecord=LAST_INSERT_ID();
SELECT * FROM Site
WHERE siteID=@lastRecord;
SELECT CAST(@lastRecord AS CHAR);
这是python:
r = {}
r = [dict((cursor.description[i][0], value)
for i, value in enumerate(row)) for row in cursor.fetchall()]
return str(json.dumps(r, default=str))
任何帮助将不胜感激。我得到一个空清单。