ADD file via upload

master
xtu202105570125 2 years ago
parent 1638b16bb3
commit de44cd5de4

921
Web.py

@ -0,0 +1,921 @@
from flask import Flask,render_template,request
import sqlite3
app= Flask(__name__)
@app.route("/")
def index():
return render_template("管理界面.html")
def show_book():
conn = sqlite3.connect("database.db")
cur=conn.cursor()
sql="SELECT * from book"
cur.execute(sql)
data_list=cur.fetchall()
conn.commit()
cur.close()
conn.close()
return data_list
def delete_book(id):
conn = sqlite3.connect("database.db")
try:
cursor = conn.cursor()
sql = "DELETE FROM book WHERE id = ?"
cursor.execute(sql,(id))
conn.commit()
except:
print("数据删除失败")
conn.rollback()
finally:
cursor.close()
conn.close()
@app.route("/书籍管理增添",methods=["GET","POST"])
def add_book():
if request.method == "GET":
return render_template("书籍管理增添.html")
id=request.form.get("id")
书名=request.form.get("书名")
作者=request.form.get("作者")
出版社ID=request.form.get("出版社ID")
出版日期=request.form.get("出版日期")
简介=request.form.get("简介")
价格=request.form.get("价格")
创建日期=request.form.get("创建日期")
更新日期=request.form.get("更新日期")
conn = sqlite3.connect("database.db")
cur=conn.cursor()
sql='INSERT INTO book VALUES(?,?,?,?,?,?,?,?,?)'
cur.execute(sql,(id,书名,作者,出版社ID,出版日期,简介,价格,创建日期,更新日期))
conn.commit()
cur.close()
conn.close()
return "添加成功!"
@app.route("/书籍列表")
def showbook():
data_list=show_book()
return render_template('书籍列表.html',data_list=data_list)
@app.route("/书籍管理删除")
def deletebook():
id=request.args['id']
delete_book(id)
data_list=show_book()
return render_template('书籍列表.html',data_list=data_list)
@app.route("/书籍管理修改",methods=["GET","POST"])
def edit_book():
if request.method == "GET":
return render_template("书籍管理修改.html")
id=request.form.get("id")
书名=request.form.get("书名")
作者=request.form.get("作者")
出版社ID=request.form.get("出版社ID")
出版日期=request.form.get("出版日期")
简介=request.form.get("简介")
价格=request.form.get("价格")
创建日期=request.form.get("创建日期")
更新日期=request.form.get("更新日期")
conn = sqlite3.connect("database.db")
cur=conn.cursor()
sql='update book set title = ?,author = ?,publisher_id = ?,publish_date = ?,description=?,price = ?,created_at = ?,updated_at = ? where id =?;'
cur.execute(sql,(书名,作者,出版社ID,出版日期,简介,价格,创建日期,更新日期,id))
conn.commit()
cur.close()
conn.close()
data_list=show_book()
return render_template('书籍列表.html',data_list=data_list)
@app.route("/书籍查询")
def Search_book():
conn = sqlite3.connect("database.db")
word=(request.args.get("word"),)
try:
cursor = conn.cursor()
sql = "SELECT * FROM book WHERE title = ?"
cursor.execute(sql,word)
sdatalist=cursor.fetchall()
conn.commit()
except:
print("数据查询失败")
conn.rollback()
finally:
cursor.close()
conn.close()
return render_template('书籍列表.html',data_list=sdatalist)
def show_publisher():
conn = sqlite3.connect("database.db")
cur=conn.cursor()
sql="SELECT * from publisher"
cur.execute(sql)
data_list=cur.fetchall()
conn.commit()
cur.close()
conn.close()
return data_list
def delete_publisher(id):
conn = sqlite3.connect("database.db")
try:
cursor = conn.cursor()
sql = "DELETE FROM publisher WHERE id = ?"
cursor.execute(sql,(id))
conn.commit()
except:
print("数据删除失败")
conn.rollback()
finally:
cursor.close()
conn.close()
@app.route("/出版社管理增添",methods=["GET","POST"])
def add_publisher():
if request.method == "GET":
return render_template("出版社管理增添.html")
id=request.form.get("id")
出版社名称=request.form.get("出版社名称")
出版社地址=request.form.get("出版社地址")
出版社邮箱=request.form.get("出版社邮箱")
出版社网站=request.form.get("出版社网站")
创建日期=request.form.get("创建日期")
更新日期=request.form.get("更新日期")
conn = sqlite3.connect("database.db")
cur=conn.cursor()
sql='INSERT INTO publisher VALUES(?,?,?,?,?,?,?)'
cur.execute(sql,(id,出版社名称,出版社地址,出版社邮箱,出版社网站,创建日期,更新日期))
conn.commit()
cur.close()
conn.close()
return "添加成功!"
@app.route("/出版社列表")
def showpublisher():
data_list=show_publisher()
return render_template('出版社列表.html',data_list=data_list)
@app.route("/出版社管理删除")
def deletepublisher():
id=request.args['id']
delete_publisher(id)
data_list=show_publisher()
return render_template('出版社列表.html',data_list=data_list)
@app.route("/出版社管理修改",methods=["GET","POST"])
def edit_publisher():
if request.method == "GET":
return render_template("出版社管理修改.html")
id=request.form.get("id")
出版社名称=request.form.get("出版社名称")
出版社地址=request.form.get("出版社地址")
出版社邮箱=request.form.get("出版社邮箱")
出版社网站=request.form.get("出版社网站")
创建日期=request.form.get("创建日期")
更新日期=request.form.get("更新日期")
conn = sqlite3.connect("database.db")
cur=conn.cursor()
sql='update publisher set id = ?,name = ?,address = ?,email = ?,website = ?,created_at = ?,updated_at = ? where id =?;'
cur.execute(sql,(id,出版社名称,出版社地址,出版社邮箱,出版社网站,创建日期,更新日期,id))
conn.commit()
cur.close()
conn.close()
data_list=show_publisher()
return render_template('出版社列表.html',data_list=data_list)
@app.route("/出版社管理跳转")
def Search_publishers():
conn = sqlite3.connect("database.db")
word=(request.args.get("出版社id"),)
try:
cursor = conn.cursor()
sql = "SELECT * FROM publisher WHERE id = ?"
cursor.execute(sql,word)
sdatalist=cursor.fetchall()
conn.commit()
except:
print("数据查询失败")
conn.rollback()
finally:
cursor.close()
conn.close()
return render_template('出版社列表.html',data_list=sdatalist)
@app.route("/出版社管理查询")
def Search_publisher():
conn = sqlite3.connect("database.db")
word=(request.args.get("word"),)
try:
cursor = conn.cursor()
sql = "SELECT * FROM publisher WHERE name = ?"
cursor.execute(sql,word)
sdatalist=cursor.fetchall()
conn.commit()
except:
print("数据查询失败")
conn.rollback()
finally:
cursor.close()
conn.close()
return render_template('出版社列表.html',data_list=sdatalist)
def show_reader():
conn = sqlite3.connect("database.db")
cur=conn.cursor()
sql="SELECT * from reader"
cur.execute(sql)
data_list=cur.fetchall()
conn.commit()
cur.close()
conn.close()
return data_list
def delete_reader(id):
conn = sqlite3.connect("database.db")
try:
cursor = conn.cursor()
sql = "DELETE FROM reader WHERE id = ?"
cursor.execute(sql,(id))
conn.commit()
except:
print("数据删除失败")
conn.rollback()
finally:
cursor.close()
conn.close()
@app.route("/读者管理增添",methods=["GET","POST"])
def add_reader():
if request.method == "GET":
return render_template("读者管理增添.html")
id=request.form.get("id")
读者姓名=request.form.get("读者姓名")
读者类别ID=request.form.get("读者类别ID")
读者性别=request.form.get("读者性别")
读者电话=request.form.get("读者电话")
读者邮箱=request.form.get("读者邮箱")
读者地址=request.form.get("读者地址")
读者身份证号码=request.form.get("读者身份证号码")
是否为管理员=request.form.get("是否为管理员")
创建时间=request.form.get("创建时间")
更新=request.form.get("更新")
conn = sqlite3.connect("database.db")
cur=conn.cursor()
sql='INSERT INTO reader VALUES(?,?,?,?,?,?,?,?,?,?,?)'
cur.execute(sql,(id,读者姓名,读者类别ID,读者性别,读者电话,读者邮箱,读者地址,读者身份证号码,是否为管理员,创建时间,更新))
conn.commit()
cur.close()
conn.close()
return "添加成功!"
@app.route("/读者列表")
def showreaderk():
data_list=show_reader()
return render_template('读者列表.html',data_list=data_list)
@app.route("/读者管理删除")
def deletereader():
id=request.args['id']
delete_reader(id)
data_list=show_reader()
return render_template('读者列表.html',data_list=data_list)
@app.route("/读者管理修改",methods=["GET","POST"])
def edit_reader():
if request.method == "GET":
return render_template("读者管理修改.html")
id=request.form.get("id")
读者姓名=request.form.get("读者姓名")
读者类别ID=request.form.get("读者类别ID")
读者性别=request.form.get("读者性别")
读者电话=request.form.get("读者电话")
读者邮箱=request.form.get("读者邮箱")
读者地址=request.form.get("读者地址")
读者身份证号码=request.form.get("读者身份证号码")
是否为管理员=request.form.get("是否为管理员")
创建时间=request.form.get("创建时间")
更新=request.form.get("更新")
conn = sqlite3.connect("database.db")
cur=conn.cursor()
sql='update reader set name = ?,reader_type_id = ?,gender = ?,phone = ?,email = ?,address=?,id_card = ?,is_admin = ?,create_at = ?,update_at = ? where id =?;'
cur.execute(sql,(读者姓名,读者类别ID,读者性别,读者电话,读者邮箱,读者地址,读者身份证号码,是否为管理员,创建时间,更新,id))
conn.commit()
cur.close()
conn.close()
data_list=show_reader()
return render_template('读者列表.html',data_list=data_list)
@app.route("/读者查询")
def Search_reader():
conn = sqlite3.connect("database.db")
word=(request.args.get("word"),)
try:
cursor = conn.cursor()
sql = "SELECT * FROM reader WHERE name = ?"
cursor.execute(sql,word)
sdatalist=cursor.fetchall()
conn.commit()
except:
print("数据查询失败")
conn.rollback()
finally:
cursor.close()
conn.close()
return render_template('读者列表.html',data_list=sdatalist)
def show_reader_type():
conn = sqlite3.connect("database.db")
cur=conn.cursor()
sql="SELECT * from reader_type"
cur.execute(sql)
data_list=cur.fetchall()
conn.commit()
cur.close()
conn.close()
return data_list
def delete_reader_type(id):
conn = sqlite3.connect("database.db")
try:
cursor = conn.cursor()
sql = "DELETE FROM reader_type WHERE id = ?"
cursor.execute(sql,(id))
conn.commit()
except:
print("数据删除失败")
conn.rollback()
finally:
cursor.close()
conn.close()
@app.route("/读者类别管理增添",methods=["GET","POST"])
def add_reader_type():
if request.method == "GET":
return render_template("读者类别管理增添.html")
id=request.form.get("id")
读者类别名称=request.form.get("读者类别名称")
最大借阅数=request.form.get("最大借阅数")
借阅天数=request.form.get("借阅天数")
续借次数=request.form.get("续借次数")
创建时间=request.form.get("创建时间")
更新时间=request.form.get("更新时间")
conn = sqlite3.connect("database.db")
cur=conn.cursor()
sql='INSERT INTO reader_type VALUES(?,?,?,?,?,?,?)'
cur.execute(sql,(id,读者类别名称,最大借阅数,借阅天数,续借次数,创建时间,更新时间))
conn.commit()
cur.close()
conn.close()
return "添加成功!"
@app.route("/读者类别列表")
def showreader_typek():
data_list=show_reader_type()
return render_template('读者类别列表.html',data_list=data_list)
@app.route("/读者类别管理删除")
def deletereader_type():
id=request.args['id']
delete_reader_type(id)
data_list=show_reader_type()
return render_template('读者类别列表.html',data_list=data_list)
@app.route("/读者类别管理修改",methods=["GET","POST"])
def edit_reader_type():
if request.method == "GET":
return render_template("读者类别管理修改.html")
id=request.form.get("id")
读者类别名称=request.form.get("读者类别名称")
最大借阅数=request.form.get("最大借阅数")
借阅天数=request.form.get("借阅天数")
续借次数=request.form.get("续借次数")
创建时间=request.form.get("创建时间")
更新时间=request.form.get("更新时间")
conn = sqlite3.connect("database.db")
cur=conn.cursor()
sql='update reader_type set name = ?,max_borrow = ?,borrow_days = ?,renew_times = ?,created_at = ?,updated_at=? where id =?;'
cur.execute(sql,(读者类别名称,最大借阅数,借阅天数,续借次数,创建时间,更新时间,id))
conn.commit()
cur.close()
conn.close()
data_list=show_reader_type()
return render_template('读者类别列表.html',data_list=data_list)
@app.route("/读者类别查询")
def Search_reader_type():
conn = sqlite3.connect("database.db")
word=(request.args.get("word"),)
try:
cursor = conn.cursor()
sql = "SELECT * FROM reader_type WHERE name = ?"
cursor.execute(sql,word)
sdatalist=cursor.fetchall()
conn.commit()
except:
print("数据查询失败")
conn.rollback()
finally:
cursor.close()
conn.close()
return render_template('读者类别列表.html',data_list=sdatalist)
@app.route("/读者管理跳转")
def Search_reader_types():
conn = sqlite3.connect("database.db")
word=(request.args.get("读者类别id"),)
try:
cursor = conn.cursor()
sql = "SELECT * FROM reader_type WHERE id = ?"
cursor.execute(sql,word)
sdatalist=cursor.fetchall()
conn.commit()
except:
print("数据查询失败")
conn.rollback()
finally:
cursor.close()
conn.close()
return render_template('读者类别列表.html',data_list=sdatalist)
def show_tag_category():
conn = sqlite3.connect("database.db")
cur=conn.cursor()
sql="SELECT * from tag_category"
cur.execute(sql)
data_list=cur.fetchall()
conn.commit()
cur.close()
conn.close()
return data_list
def delete_tag_category(id):
conn = sqlite3.connect("database.db")
try:
cursor = conn.cursor()
sql = "DELETE FROM tag_category WHERE id = ?"
cursor.execute(sql,(id))
conn.commit()
except:
print("数据删除失败")
conn.rollback()
finally:
cursor.close()
conn.close()
@app.route("/标签分类管理增添",methods=["GET","POST"])
def add_tag_category():
if request.method == "GET":
return render_template("标签分类管理增添.html")
id=request.form.get("id")
标签分类名称=request.form.get("标签分类名称")
创建时间=request.form.get("创建时间")
更新时间=request.form.get("更新时间")
conn = sqlite3.connect("database.db")
cur=conn.cursor()
sql='INSERT INTO tag_category VALUES(?,?,?,?)'
cur.execute(sql,(id,标签分类名称,创建时间,更新时间))
conn.commit()
cur.close()
conn.close()
return "添加成功!"
@app.route("/标签分类列表")
def sho_tag_category():
data_list=show_tag_category()
return render_template('标签分类列表.html',data_list=data_list)
@app.route("/标签分类管理删除")
def delet_tag_category():
id=request.args['id']
delete_tag_category(id)
data_list=show_tag_category()
return render_template('标签分类列表.html',data_list=data_list)
@app.route("/标签分类管理修改",methods=["GET","POST"])
def edit_tag_category():
if request.method == "GET":
return render_template("标签分类管理修改.html")
id=request.form.get("id")
标签分类名称=request.form.get("标签分类名称")
创建时间=request.form.get("创建时间")
更新时间=request.form.get("更新时间")
conn = sqlite3.connect("database.db")
cur=conn.cursor()
sql='update tag_category set name = ?,created_at = ?,updated_at = ? where id =?;'
cur.execute(sql,(标签分类名称,创建时间,更新时间,id))
conn.commit()
cur.close()
conn.close()
data_list=show_tag_category()
return render_template('标签分类列表.html',data_list=data_list)
@app.route("/标签分类查询")
def Search_tag_category():
conn = sqlite3.connect("database.db")
word=(request.args.get("word"),)
try:
cursor = conn.cursor()
sql = "SELECT * FROM tag_category WHERE title = ?"
cursor.execute(sql,word)
sdatalist=cursor.fetchall()
conn.commit()
except:
print("数据查询失败")
conn.rollback()
finally:
cursor.close()
conn.close()
return render_template('标签分类列表.html',data_list=sdatalist)
def show_book_tag():
conn = sqlite3.connect("database.db")
cur=conn.cursor()
sql="SELECT * from book_tag"
cur.execute(sql)
data_list=cur.fetchall()
conn.commit()
cur.close()
conn.close()
return data_list
def delete_book_tag(book_id):
conn = sqlite3.connect("database.db")
try:
print(book_id)
cursor = conn.cursor()
sql = "DELETE FROM book_tag WHERE book_id = ?"
cursor.execute(sql,(book_id))
conn.commit()
except:
print("数据删除失败")
conn.rollback()
finally:
cursor.close()
conn.close()
@app.route("/书籍标签信息管理增添",methods=["GET","POST"])
def add_book_tag():
if request.method == "GET":
return render_template("书籍标签信息管理增添.html")
书籍id=request.form.get("书籍id")
标签id=request.form.get("标签id")
创建日期=request.form.get("创建日期")
更新日期=request.form.get("更新日期")
conn = sqlite3.connect("database.db")
cur=conn.cursor()
sql='INSERT INTO book_tag VALUES(?,?,?,?)'
cur.execute(sql,(书籍id,标签id,创建日期,更新日期))
conn.commit()
cur.close()
conn.close()
return "添加成功!"
@app.route("/书籍标签信息列表")
def showbook_tag():
data_list=show_book_tag()
return render_template('书籍标签信息列表.html',data_list=data_list)
@app.route("/书籍标签信息管理删除")
def deletebook_tag():
book_id=request.args['book_id']
delete_book_tag(book_id)
data_list=show_book_tag()
return render_template('书籍标签信息列表.html',data_list=data_list)
@app.route("/书籍标签信息管理修改",methods=["GET","POST"])
def edit_book_tag():
if request.method == "GET":
return render_template("书籍标签信息管理修改.html")
书籍id=request.form.get("书籍id")
标签id=request.form.get("标签id")
创建日期=request.form.get("创建日期")
更新日期=request.form.get("更新日期")
conn = sqlite3.connect("database.db")
cur=conn.cursor()
sql='update book_tag set book_id = ?,tag_id = ?,created_at = ?,updated_at = ? where book_id =?;'
cur.execute(sql,(书籍id,标签id,创建日期,更新日期,书籍id))
conn.commit()
cur.close()
conn.close()
data_list=show_book_tag()
return render_template('书籍标签信息列表.html',data_list=data_list)
@app.route("/书籍标签信息查询")
def Search_book_tag():
conn = sqlite3.connect("database.db")
word=(request.args.get("word"),)
try:
cursor = conn.cursor()
sql = "SELECT * FROM book_tag WHERE book_id = ?"
cursor.execute(sql,word)
sdatalist=cursor.fetchall()
conn.commit()
except:
print("数据查询失败")
conn.rollback()
finally:
cursor.close()
conn.close()
return render_template('书籍标签信息列表.html',data_list=sdatalist)
@app.route("/书籍标签信息管理跳转书籍信息")
def Search_book_s():
conn = sqlite3.connect("database.db")
word=(request.args.get("书籍id"),)
try:
cursor = conn.cursor()
sql = "SELECT * FROM book WHERE id = ?"
cursor.execute(sql,word)
sdatalist=cursor.fetchall()
conn.commit()
except:
print("数据查询失败")
conn.rollback()
finally:
cursor.close()
conn.close()
return render_template('书籍列表.html',data_list=sdatalist)
@app.route("/书籍标签信息管理跳转标签信息")
def Search_tag_s():
conn = sqlite3.connect("database.db")
word=(request.args.get("标签id"),)
try:
cursor = conn.cursor()
sql = "SELECT * FROM tag WHERE id = ?"
cursor.execute(sql,word)
sdatalist=cursor.fetchall()
conn.commit()
except:
print("数据查询失败")
conn.rollback()
finally:
cursor.close()
conn.close()
return render_template('标签列表.html',data_list=sdatalist)
def show_tag():
conn = sqlite3.connect("database.db")
cur=conn.cursor()
sql="SELECT * from tag"
cur.execute(sql)
data_list=cur.fetchall()
conn.commit()
cur.close()
conn.close()
return data_list
def delete_tag(id):
conn = sqlite3.connect("database.db")
try:
cursor = conn.cursor()
sql = "DELETE FROM tag WHERE id = ?"
cursor.execute(sql,(id))
conn.commit()
except:
print("数据删除失败")
conn.rollback()
finally:
cursor.close()
conn.close()
@app.route("/标签管理增添",methods=["GET","POST"])
def add_tag():
if request.method == "GET":
return render_template("标签管理增添.html")
id=request.form.get("id")
标签名称=request.form.get("标签名称")
作者标签所属分类ID=request.form.get("标签所属分类ID")
创建时间=request.form.get("创建时间")
更新时间=request.form.get("更新时间")
conn = sqlite3.connect("database.db")
cur=conn.cursor()
sql='INSERT INTO tag VALUES(?,?,?,?,?)'
cur.execute(sql,(id,标签名称,作者标签所属分类ID,创建时间,更新时间))
conn.commit()
cur.close()
conn.close()
return "添加成功!"
@app.route("/标签列表")
def sho_tag():
data_list=show_tag()
return render_template('标签列表.html',data_list=data_list)
@app.route("/标签管理删除")
def delet_tag():
id=request.args['id']
delete_tag(id)
data_list=show_tag()
return render_template('标签列表.html',data_list=data_list)
@app.route("/标签管理修改",methods=["GET","POST"])
def edit_tag():
if request.method == "GET":
return render_template("标签管理修改.html")
id=request.form.get("id")
标签名称=request.form.get("标签名称")
作者标签所属分类ID=request.form.get("标签所属分类ID")
创建时间=request.form.get("创建时间")
更新时间=request.form.get("更新时间")
conn = sqlite3.connect("database.db")
cur=conn.cursor()
sql='update tag set name = ?,category_id = ?,created_at = ?,updated_at = ? where id =?;'
cur.execute(sql,(标签名称,作者标签所属分类ID,创建时间,更新时间,id))
conn.commit()
cur.close()
conn.close()
data_list=show_tag()
return render_template('标签列表.html',data_list=data_list)
@app.route("/标签查询")
def Search_tag():
conn = sqlite3.connect("database.db")
word=(request.args.get("word"),)
try:
cursor = conn.cursor()
sql = "SELECT * FROM tag WHERE title = ?"
cursor.execute(sql,word)
sdatalist=cursor.fetchall()
conn.commit()
except:
print("数据查询失败")
conn.rollback()
finally:
cursor.close()
conn.close()
return render_template('标签列表.html',data_list=sdatalist)
@app.route("/标签管理跳转")
def Search_tags():
conn = sqlite3.connect("database.db")
word=(request.args.get("标签分类id"),)
try:
cursor = conn.cursor()
sql = "SELECT * FROM tag_category WHERE id= ?"
cursor.execute(sql,word)
sdatalist=cursor.fetchall()
conn.commit()
except:
print("数据查询失败")
conn.rollback()
finally:
cursor.close()
conn.close()
return render_template('标签分类列表.html',data_list=sdatalist)
def show_borrow():
conn = sqlite3.connect("database.db")
cur=conn.cursor()
sql="SELECT * from borrow"
cur.execute(sql)
data_list=cur.fetchall()
conn.commit()
cur.close()
conn.close()
return data_list
def delete_borrow(id):
conn = sqlite3.connect("database.db")
try:
cursor = conn.cursor()
sql = "DELETE FROM borrow WHERE id = ?"
cursor.execute(sql,(id))
conn.commit()
except:
print("数据删除失败")
conn.rollback()
finally:
cursor.close()
conn.close()
@app.route("/借阅管理增添",methods=["GET","POST"])
def add_borrow():
if request.method == "GET":
return render_template("借阅管理增添.html")
id=request.form.get("id")
读者id=request.form.get("读者id")
书籍id=request.form.get("书籍id")
借阅日期=request.form.get("借阅日期")
归还日期=request.form.get("归还日期")
conn = sqlite3.connect("database.db")
cur=conn.cursor()
sql='INSERT INTO borrow VALUES(?,?,?,?,?)'
cur.execute(sql,(id,读者id,书籍id,借阅日期,归还日期))
conn.commit()
cur.close()
conn.close()
return "添加成功!"
@app.route("/借阅列表")
def showborrow():
data_list=show_borrow()
return render_template('借阅列表.html',data_list=data_list)
@app.route("/借阅管理删除")
def deleteborrow():
id=request.args['id']
delete_borrow(id)
data_list=show_borrow()
return render_template('借阅列表.html',data_list=data_list)
@app.route("/借阅管理修改",methods=["GET","POST"])
def edit_borrow():
if request.method == "GET":
return render_template("借阅管理修改.html")
id=request.form.get("id")
读者id=request.form.get("读者id")
书籍id=request.form.get("书籍id")
借阅日期=request.form.get("借阅日期")
归还日期=request.form.get("归还日期")
conn = sqlite3.connect("database.db")
cur=conn.cursor()
sql='update borrow set reader_id = ?,book_id = ?,borrow_date = ?,return_date = ? where id =?;'
cur.execute(sql,(读者id,书籍id,借阅日期,归还日期,id))
conn.commit()
cur.close()
conn.close()
data_list=show_borrow()
return render_template('借阅列表.html',data_list=data_list)
@app.route("/借阅查询")
def Search_borrow():
conn = sqlite3.connect("database.db")
word=(request.args.get("word"),)
try:
cursor = conn.cursor()
sql = "SELECT * FROM borrow WHERE id = ?"
cursor.execute(sql,word)
sdatalist=cursor.fetchall()
conn.commit()
except:
print("数据查询失败")
conn.rollback()
finally:
cursor.close()
conn.close()
return render_template('借阅列表.html',data_list=sdatalist)
@app.route("/借阅管理跳转读者信息")
def Search_readers():
conn = sqlite3.connect("database.db")
word=(request.args.get("读者id"),)
try:
cursor = conn.cursor()
sql = "SELECT * FROM reader WHERE id = ?"
cursor.execute(sql,word)
sdatalist=cursor.fetchall()
conn.commit()
except:
print("数据查询失败")
conn.rollback()
finally:
cursor.close()
conn.close()
return render_template('读者列表.html',data_list=sdatalist)
if __name__ == '__main__':
app.run()
Loading…
Cancel
Save