many refinements

This commit is contained in:
2025-11-02 15:20:34 -08:00
parent a9681e2c94
commit 982b7a374d
12 changed files with 169 additions and 170 deletions

View File

@ -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():