I read a bunch of posts about this, couldn't make it work here though (apologies in advance)
(Python version 3.7.0) I have a SQLite3 database:
cursor.execute("""CREATE TABLE everyone(NAME text primary key, ROLE text, SECTION text, USED text)""")
The data looks like this in the table:
I'm pulling x amount of names at random, where Role = FLM
results = cursor.fetchall()
for i in range(3):
names = secure_random.choice(results)
print(f'{names}')
This gives me the names I want, and when I print I see:
('Joe Blow 12345',)
I now want to delete Joe Blow from the list completely, OR enter something in the "Used" field (which is just a work around because I couldn't seem to delete)
Here's my code containing the selection of people, and my attempt to update:
results = cursor.fetchall()
for i in range(3):
names = secure_random.choice(results)
print(f'{names}')
#try:
#cursor.execute(f'''UPDATE everyone SET USED = "Y" WHERE NAME = {names} ''')
#except:
#print('Something went wrong updating names in the database.')
try:
execute('''UPDATE everyone SET USED = ? WHERE NAME = ?''', (used_var, names))
except:
print('Something went wrong updating names in the database.')
break
No matter how I try this, I can't get it right.
For this:
cursor.execute('''UPDATE everyone SET USED = ? WHERE NAME = ?''', (used_var, names))
I get "InterfaceError: Error binding parameter 1 - probably unsupported type."
For this:
cursor.execute(f'''UPDATE everyone SET USED = "Y" WHERE NAME = {names} ''')
I get "OperationalError: near ")": syntax error"
I didn't think to record all of the different ways I've tried, I'd really appreciate some help!

used_var?