def equip_tianjia(): db = pymysql.connect("localhost", "root", "123456", "opcdata") cursor = db.cursor() addr = request.args.get('addr') jing, wei = getlnglat(addr) jing_wei = str(jing) + '|' + str(wei) sql = "insert into equip_info(equipment_id,model,link_method,sale_date,linkman,addr,jing_wei,contacts,baoxiu,other) values" + \ '(' + repr(request.args.get('equipment_id')) + ',' + \ repr(request.args.get('model')) + ',' + \ repr(request.args.get('link_method')) + ',' + \ repr(request.args.get('sale_date')) + ',' + \ repr(request.args.get('linkman')) + ',' + \ repr(request.args.get('addr')) + ',' + \ repr(jing_wei) + ',' + \ repr(request.args.get('contacts')) + ',' + \ repr(request.args.get('baoxiu')) + ',' + \ repr(request.args.get('other')) + ')' print(sql) try: # 执行sql语句 cursor.execute(sql) db.commit() do_thing = "用户:{yonghu},进行了添加设备操作".format( yonghu=session.get('username')) log_record(do_thing=do_thing) return redirect('/equip_map/position') except: # 如果发生错误则回滚 traceback.print_exc() db.rollback() flash('对不起添加失败le') return render_template('position_add.html') # 关闭数据库连接 db.close()
def equip_mod(): db = pymysql.connect("localhost", "root", "123456", "opcdata") cursor = db.cursor() addr = request.args.get('addr') jing, wei = getlnglat(addr) jing_wei = str(jing) + '|' + str(wei) sql = "update equip_info set sale_date="+repr(request.args.get('sale_date')) + ',' + \ "link_method=" + repr(request.args.get('link_method')) + ',' + \ "linkman="+repr(request.args.get('linkman')) + ',' +\ "addr="+repr(request.args.get('addr')) + ',' + \ "jing_wei=" + repr(jing_wei) + ',' + \ "contacts=" + repr(request.args.get('contacts')) + ',' + \ "baoxiu=" + repr(request.args.get('baoxiu')) + ',' + \ "other=" + repr(request.args.get('other')) + \ " where equipment_id=" + repr(request.args.get('equipment_id')) print(sql) try: # 执行sql语句 cursor.execute(sql) db.commit() do_thing = "用户:{yonghu},进行了修改设备操作".format( yonghu=session.get('username')) log_record(do_thing=do_thing) return redirect('/equip_map/position') except: # 如果发生错误则回滚 traceback.print_exc() db.rollback() flash('对不起添加失败le') return render_template('equip_modify.html') # 关闭数据库连接 db.close()
def remove_equip(equipment_id): print('删除设备') if equipment_id: db = pymysql.connect("localhost", "root", "123456", "opcdata") cursor = db.cursor() sql = "Delete FROM equip_info where equipment_id=" + repr(equipment_id) print(sql) try: cursor.execute(sql) db.commit() do_thing = "用户:{yonghu},删除设备操作执行成功".format( yonghu=session.get('username')) log_record(do_thing) except: # 如果发生错误则回滚 traceback.print_exc() db.rollback() db.close() return redirect('/equip_map/position')