我正在尝试使用以下查询更新SQL服务器中的表,但我收到错误消息。我最初创建了这个表但却错误地命名了这些列。
cursor = con.cursor()
table_name = 'current_bestsellers'
create_table_query = '''UPDATE current_bestsellers
(list_name varchar(250),
display_name varchar(250),
bestsellers_date varchar(250),
published_date varchar(250),
rank int,
rank_last_week int,
weeks_on_list int,
isbns varchar(250),
title varchar(250),
description varchar(250),
author varchar(250)
price int,
age_group varchar(250),
publisher varchar(250),
PRIMARY KEY(isbns)
)'''.format(db=db_name, table=table_name)
cursor.execute(create_table_query)
cursor.close()
我正在使用纽约时报畅销书列表Web API来获取数据。网站文档部分显示的模式粘贴在下面。
{
status:"string",
copyright:"string",
num_results:integer,
last_modified:"string",
results:[
{
list_name:"string",
display_name:"string",
bestsellers_date:"string",
published_date:"string",
rank:integer,
rank_last_week:integer,
weeks_on_list:integer,
asterisk:integer,
dagger:integer,
amazon_product_url:"string",
isbns:[
{
isbn10:"string",
isbn13:"string"
}
],
book_details:[
{
title:"string",
description:"string",
contributor:"string",
author:"string",
contributor_note:"string",
price:integer,
age_group:"string",
publisher:"string",
primary_isbn13:"string",
primary_isbn10:"string",
}
],
reviews:[
{
book_review_link:"string",
first_chapter_link:"string",
sunday_review_link:"string",
article_chapter_link:"string"
}
]
}
]
}
一旦我到达isbns,我无法让我的代码工作,因为数据是嵌套的,以及标题,作者等的数据。