Django 我无法使用DOTA2API为我的数据库提供API
当我运行insert_herones.py文件时,我得到了这个图像 插入_.pyDjango 我无法使用DOTA2API为我的数据库提供API,django,postgresql,api,graphql,Django,Postgresql,Api,Graphql,当我运行insert_herones.py文件时,我得到了这个图像 插入_.py import requests import json if __name__ == '__main__': r = requests.get("https://api.opendota.com/api/heroes") all_heroes_info = json.loads(r.content.decode('UTF-8')) for hero_info in all_heroes_
import requests
import json
if __name__ == '__main__':
r = requests.get("https://api.opendota.com/api/heroes")
all_heroes_info = json.loads(r.content.decode('UTF-8'))
for hero_info in all_heroes_info:
name = hero_info['localized_name']
hero_type = hero_info['primary_attr']
mutation_create_hero = '''
mutation ($name: String!, $heroType: String!) {
createHero(name: $name, heroType: $heroType) {
name
}
}
'''
fill_db = mutation_create_hero, variable_values = {'name': name, 'heroType': hero_type}
print(fill_db)
我创建了一个名为fill_db的变量,它等于将从dota2api创建所有新英雄的变异,然后我刚刚打印了fill_db。
我从那个get请求中得到了所有的英雄,但问题是我现在不知道如何将所有这些都推送到我的postgreSQL数据库中。我不知道怎么做
我需要某种命令,将这个参数和变异放在方括号中作为参数,比如client.execute()
你们能帮帮我吗 您提供的链接不会打开任何图像!请修复它打开图像,这里是再次->