0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

メモ

Posted at

#4
@app.route('/EmployeeSystem/int:id', methods=['PUT'])
def EmployeeSystemPUT(id):
    json=request.get_json()
    name=json.get('name')
    data={'id':id, 'name':name}
    dbname='employee_info.db'
    conn=sqlite3.connect(dbname)
    cur=conn.cursor()
    if type(name) is int:
        return jsonify({'message': "データの形式が違います"}),400
    elif not name:
        return jsonify({'message': "データが入力されていません"}),400
    else:
            cur.execute('update info set name=? where id=?',[name,id])
            change=cur.rowcount;
            try:
                if change>0:
                    conn.commit()
                    conn.close()
                    return jsonify(data),200
                elif change==0:
                    conn.close()
                    raise IDerror("その社員IDは存在しません")
             except IDerror as e:
                  data={'message':e}
                  return jsonify(data),404

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?