我尝试了flask-peewee / peewee示例。查询成功运行但它不返回新行PK。
这是我的代码:
@app.route('/api/merchant/invoice/', methods=['POST'])
def merchantInvoice():
if request.method == 'POST' and request.form['checkin_id']:
active = checkin_details.select().where(checkin_details.is_active==True)
try:
checkin = active.where(checkin_details.id == request.form['checkin_id']).get()
sale=Sales(
checkin_id=checkin.id,
merchant_id =checkin.merchant_id,
created_at=datetime.datetime.now(),
sale_amount=request.form['amount'],
user_id=checkin.user_id
)
sale.save()
return sale_id=sale.id