many refinements
This commit is contained in:
@ -4,14 +4,19 @@ import json
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
# Function to get all drive records from the database
|
||||
def get_all_drive_records():
|
||||
# sqlite query function
|
||||
def query_db(sql_query):
|
||||
conn = sqlite3.connect('drive_records.db')
|
||||
cursor = conn.cursor()
|
||||
cursor.execute("SELECT * FROM drive_records")
|
||||
cursor.execute(sql_query)
|
||||
rows = cursor.fetchall()
|
||||
conn.close()
|
||||
|
||||
return rows
|
||||
|
||||
# Function to return all drive records in database
|
||||
def get_all_drive_records():
|
||||
get_all_drives = "SELECT * FROM drive_records"
|
||||
rows = query_db(get_all_drives)
|
||||
drives = []
|
||||
for row in rows:
|
||||
drive = {
|
||||
@ -28,13 +33,8 @@ def get_all_drive_records():
|
||||
|
||||
# Function to check if a serial number exists in the database
|
||||
def check_serial_exists(serial):
|
||||
conn = sqlite3.connect('drive_records.db')
|
||||
cursor = conn.cursor()
|
||||
cursor.execute("SELECT * FROM drive_records WHERE serial=?", (serial,))
|
||||
row = cursor.fetchone()
|
||||
conn.close()
|
||||
return bool(row)
|
||||
|
||||
return bool(query_db("SELECT * FROM drive_records WHERE serial=?", (serial,)))
|
||||
|
||||
# Route to check if a serial number exists in the database
|
||||
@app.route('/check', methods=['GET'])
|
||||
def check():
|
||||
|
||||
Reference in New Issue
Block a user