Python 将复杂json对象插入sql模式

Python 将复杂json对象插入sql模式,python,mysql,sql,Python,Mysql,Sql,我有一个格式为 { "483329": {"Dairy_free": false, "Gluten_free": true, "Vegetarian": false, "Vegan": false, "ketagonic": false}, "577539": {"Dairy_free": true, "Gluten_free": false, "Vegetarian": true

我有一个格式为

{   
    "483329": 
    {"Dairy_free": false,
     "Gluten_free": true,
     "Vegetarian": false,
     "Vegan": false, 
     "ketagonic": false},

     "577539": 
     {"Dairy_free": true,
      "Gluten_free": false, 
      "Vegetarian": true, 
      "Vegan": true, 
      "ketagonic": false}
}
其中模式为

    | id | Dairy_free | Gluten_free | Vegetarian | Vegan|  ketagonic|
    +----+------------+-------------+------------+------+-----------+

有没有一种不重新生成json的方法,可以使用mysqlcursors将json对象插入mysql?

sql_insert = INSERT INTO allergies VALUES (Default, %s %s %s %s %s);"
cursor = config.cursor
for obj in json_objects <---- this is where I need to transfer to suitable object
try:
    affected_count = cursor.execute(sql_insert, (object))
    config.dbconnection.commit()
except Exception as e:
    print e
sql\u insert=插入到过敏值中(默认值,%s%s%s);"
cursor=config.cursor

对于json_对象中的obj,它可以使用executemany,后跟from


提取JSON数据的时间间隔是多少。您是否发出任何get请求?
data = list(map(lambda x: tuple(x.values()), json_objects.values()))
# [(False, True, False, False, False), (True, False, True, True, False)]

c.executemany(
    """INSERT INTO allergies VALUES (Default, %s, %s, %s, %s, %s)""",
    data
)