def insert_pdf_to_db(pdf_name):
# insert a pdf into the database and return his id
path = app.config['PDF_DIR_LOC'] + app.config['PDF_DIR'] + pdf_name
conn = conn_to_db('pdf.db')
cursor = conn.execute("INSERT INTO PDF (NAME, HASH, DATE) VALUES ('{}', '{}', {})".format(
pdf_name, hash_file(path), int(time())))
conn.commit()
pdf_id = cursor.lastrowid
conn.close()
return pdf_id
评论列表
文章目录