I am trying to dynamically call a a fieldname that has a number that changes. Example I have Hard4, Hard6, Hard8, Hard10 as fields and want to call them based on a roll. I currently get a syntax error and I cannot find anyway to to fix in by searching stackoverflow :(.
Any help would be grateful! CODE:
conn = sqlite3.connect('C:\sqlite\crapsdatabase.db')
c = conn.cursor()
die1 = 3
die2 = 3
theroll = die1+die2
if die1 == die2:
c.execute("SELECT playerName FROM player WHERE Hard? > 1", (theroll,))
for row in c:
for field in row:
print(field)
Error:
c.execute("SELECT playerName FROM player WHERE Hard? > 1", (theroll,))
sqlite3.OperationalError: near "?": syntax error
This is using python 3 if that makes a major difference. I also tried putting the ? in single quotes...
Thank you again for looking!
Aucun commentaire:
Enregistrer un commentaire