def addPatron(fn, ln): conn = sqlite3.connect(Config.getDBFileName()) c = conn.cursor() fn = fn.upper() ln = ln.upper() date = getAmerDate() record = (fn, ln, date) c.execute('INSERT INTO vcl VALUES (?,?,?)', record) conn.commit() conn.close()
def checkForBan(lnfn): conn = sqlite3.connect(Config.getDBFileName()) c = conn.cursor() lnfnarr = nameVAndF(lnfn) if not lnfnarr: return ["ERROR: Incorrect formatting."] ln = lnfnarr[0] fn = lnfnarr[1] c.execute('SELECT * FROM banned_patrons WHERE fname=? AND lname=?', (fn, ln)) res = c.fetchall() conn.close() if res: return res[0] else: return False
def addBannedPatron(fn, ln, bd, ed, barcode, muni, reason, additional_info): current_table = getAll('banned_patrons') if not current_table: logTC("First record created") idnum = 1 else: highest = current_table[0][0] for record in current_table: if record[0] > highest: highest = record[0] else: pass idnum = highest + 1 conn = sqlite3.connect(Config.getDBFileName()) c = conn.cursor() fn = fn.upper() ln = ln.upper() muni = muni.upper() record = (idnum, fn, ln, bd, ed, barcode, muni, reason, additional_info) c.execute('INSERT INTO banned_patrons VALUES (?,?,?,?,?,?,?,?,?)', record) conn.commit() conn.close()
def checkForDB(): try: conn = sqlite3.connect(Config.getDBFileName()) conn.close() except sqlite3.Error: return False