尝试将“counts”列表从第一个函数拉入第二个函数以更新表。你知道吗
我在使用Python,SQLAlchemy,sqlite。我觉得问题出在我的Python身上。是名单吗,塔普?我该怎么做?你知道吗
def countCurrentOccupancy():
p = session.query(Puppy.shelter_id, func.count(Puppy.shelter_id))
grouped_count = p.group_by (Puppy.shelter_id).all()
return grouped_count
def updateCurrentOccupancy():
l = countCurrentOccupancy()
list_c = list(l)
s = session.query(Shelter.shelter_id, Shelter.current_occupancy)
print 'updateCurrentOccupancy:'
print '----------------------'
for row_s in s:
row_s = list_c #Trying to pull matching data from countCurrentOccupancy(), will update to an integer that I choose but that is not helpful.
print row_s
session.commit(row_s)
showShelter()
结果:
TypeError: commit() takes exactly 1 argument (2 given)
您可以将列表转换为dict{shelter\u id:count},并通过
shelter_id
获得count
相关问题 更多 >
编程相关推荐