def add_todo ( request ) : cur = request . cursor todo = request . json [ "todo" ] cur . execute ( """INSERT INTO todos (todo) VALUES (?)""" , ( todo , ) ) last_id = cur . lastrowid cur . connection . commit ( ) return request . Response ( json = { "id" : last_id , "todo" : todo } )
get last inserted id from mongodb collection python
def add_todo(request):
    cur = request.cursor
    todo = request.json["todo"]
    cur.execute("""INSERT INTO todos (todo) VALUES (?)""", (todo,))
    last_id = cur.lastrowid
    cur.connection.commit()

    return request.Response(json={"id": last_id, "todo": todo})