0
我想在使用SQLAlchemy插入postgresql後獲取最後插入的記錄的ID。下面是代碼,Python SQLAlchemy在插入後得到重調ID
insert_record = {list of data}
result = connection.execute(tbl_example.insert().returning(tbl_example.c.id), insert_record)
print result.id
的插入確實不錯,但我似乎無法得到最後插入,我得到以下錯誤的ID,
AttributeError: 'ResultProxy' object has no attribute 'id'
哪裏返回ID位於返回的對象?
像'''row_id = result ['id']'''給了我這樣的錯誤''TypeError:'ResultProxy'對象沒有屬性'__getitem __''''' – rksh