如果条件
我正在尝试将API查询响应插入到SQL Server数据库中。在特定字段上,我需要检查查询响应中字段的值是对还是错误,如果是false,则需要插入“ f”,如果它是真的,我需要在DB中插入“ T”字段,
cursor = sqlconn.cursor()
for index,row in roomsDF.iterrows():
cursor.execute("INSERT INTO SurplusMouse.RM_Room(ROOMID, NAME, DESCRIPTION, SHIPPING_FREEZE, UPDATEDNAME)\
values(?,?,?,?,?)"
,row['id']
,row['name']
,row['description']
, if row['shippingFreeze'] == false:
'F'
else:
'T'
,row['shippingFreeze'].split(' ', 1)
)
我看到这里的两个错误在 cursor.execute上一个错误(“
as ”(“没有关闭
,另一个问题是
eresence Expression pylance pylance
erroron the 如果
。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在我看来,您正在混合两个不同的概念。您需要分裂和征服。
检索数据,并为每个值创建一个变量。
然后,创建execute命令。确保运输属性正确地格式化为布尔值。
关于
L.
It seems to me you are mixing two different concepts. You need to divide and conquer.
Retrieve the data, and create a variable for each value.
Then, create the execute command. Make sure that the shippingFreeze attribute comes correctly formatted as boolean.
Regards
L.