我在mysql workbench 5.7中创建了5个表,我将从APIgraph查询中为给定的Facebook页面提取数据。Python中的SQL%语句返回错误
然而,当我运行的代码,它抛出一个错误:
ProgrammingError: 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 '%s, %s)' at line 1
这是我认为的代码部分包含错误:
#create connection to db
connection = connect_db()
cursor = connection.cursor()
#SQL request for inserting the date of the page into the database
insert_page = ("INSERT INTO page"
"(fb_id, name)"
"VALUES (%s, %s)")
insert_posts = ("INSERT INTO posts "
"(page_id, fb_post_id, message, time_created)"
"VALUES (%s, %s, %s, %s)")
我终于把数据在代码的末尾:
cursor.execute(insert_page, json_pageiddata)
任何想法?感谢您的帮助
编辑:这里是我的json_pageiddtata可变的,APIgraph从URL查询得到:
pageid_url = create_pageid_url(current_page, APP_ID, APP_SECRET)
json_pageiddata = render_to_json(pageid_url)
print json_pageiddata["name"], json_pageiddata["id"]
你可以通过你的''json_pageiddata''变量 –
嗨,我更新了我的问题与您的需求! –