So i was trying to use a local varibale made in python to be used in my SQL statement but I get the error sqlite3.OperationalError: unrecognized token: "1AM"
if schchoice==int("1"):
schchoice=str("12AM")
elif schchoice == int("2"):
schchoice="1AM"
else:
print("INVALID")
if schchoice2==int("1"):
schchoice=str("12AM")
elif schchoice2==int("2"):
schchoice2="1AM"
else:
print("INVALID")
conn = sqlite3.connect('Employee.db')
c = conn.cursor()
def read_from_db():
c.execute("SELECT FName,LName, monstarthour, monendhour FROM MondayHours WHERE monstarthour ='"+schchoice+"'AND monendhour='"+schchoice2+'"')
#data = c.fetchall()
for row in c.fetchall():
print(row)
read_from_db()
string.format()instead:c.execute("SELECT FName,LName, monstarthour, monendhour FROM MondayHours WHERE monstarthour='{}' AND monendhour='{}'".format(schoice, schoice2))