我试图编写一个程序,从api调用中获取一个json对象,然后将其加载到数据库中。当我编译stmt
或尝试单独执行时,sqlalchemy不断抛出错误AttributeError: 'TextClause' object has no attribute 'implicit_returning'
。在
def load_results(self):
connect = self.engine.connect()
for ru in self.json_ru:
counties = ru['counties']
for county in counties:
transaction = connect.begin()
params = {"reportingunitName": ru['reportingunitName'],
"geoCode": ru['geocode'],
"townsTotal": ru['towns'],
"townsReporting": ru['townsReporting'],
"cableName": county['cableName'],
"unitCount": county['unitCount']
}
stmt = expression.insert('{}.raw_feed'.format(self.state)).values(params)
compiled_stmt = stmt.compile(self.engine)
connect.execute(compiled_stmt)
transaction.commit()
在我提出疑问之前连接.执行,但是作为值传入的字符串被作为列名读取,因此我尝试了上面的方法。也使用Postgres口味。在
目前没有回答
相关问题 更多 >
编程相关推荐