我编写了一个代码,使用pymysql从mysql数据库读取2列(raw_id,注释),这给了我字典的列表。现在,我想提取id值,进行存储,并使用记录级别的每个raw_id的注释列值更新评论列。有人可以帮我吗?
db_data包含:
big_df <- data.frame("ID" = 1:10, "Age" = c(21,15,1,20,34,45,67,87,9,77), "Name" = c("a","b","c","d","e","f","g","h","i","l"))
small_df <- data.frame("ID" = c(1,4,8,9), "Colour" = c("blue","green","red","black"))
library(dplyr)
semi_join(big_df,small_df,by='ID')
#
# ID Age Name
# 1 1 21 a
# 2 4 20 d
# 3 8 87 h
# 4 9 9 i
我使用的代码:
[OrderedDict([(u'raw_id', u'52c00'), (u'notes', u'awesome')]),
OrderedDict([(u'raw_id', u'54df0'), (u'notes', u'loved it')]),
OrderedDict([(u'raw_id', u'5cd00'), (u'notes', u'enjoyed')]),...]
我遇到的错误:
for row in db_data:
text = row.values()
r_id = text[0]
update_sql = "update raw_data set review = notes where
customer_id = {0} and raw_id = {1}"
res = sql_db.execute_write(update_sql, [inp_cust_id, r_id])
print res
答案 0 :(得分:0)
for row in db_data:
text = str(row.values())
r_id = str(text[0])
update_sql = "update raw_data set review = notes where
customer_id = {0} and raw_id = {1}"
res = sql_db.execute_write(update_sql, [inp_cust_id, r_id])
print res
尝试