I am currently working on a discord bot that implements some kind of economy into the server.
While implementing a function to add items to the SQLite Database I ran into this problem:
cur.execute("INSERT INTO items (?,?,?,?,?,?)", item)
sqlite3.OperationalError: near "?": syntax error
I already switched to "?" as placeholder thanks to this post and found this post but it didn't help me much.
All values are gotten via arguments to the command in discord and are cast to either string or int. I use SQLiteStudio and have the datatypes set to "Text" and "Integer" respectively.
conn = create_connection(db_file)
with conn:
cur = conn.cursor()
item = (itemname, price, info_text, buy_text, use_text, role,)
market = (itemname, stock,)
cur.execute("INSERT INTO items (?,?,?,?,?,?)", item)
cur.execute("INSERT INTO market (?,?)", market)
INSERT INTO table (col1, col2, ...) VALUES (val1, val2, ...), .... The column list is optional if you're inserting values for every column.