Reputation: 140
I think I'm updating my database wrong? It's not giving me a error, so it's probably something that I forgot to do or didn't notice. Anyways, I'm super stumped and the tutorial I was watching didn't have this problem.
Thanks for all the help in advance!
@bot.command(aliases = ['gen' , 'newacc'])
async def open_account(tendant):
db = sqlite3.connect('leveling.sqlite')
cursor = db.cursor()
sqlupdate = (f'INSERT INTO leveling(user_id,xp, local_xp) VALUES(?,?,?)')
val = (tendant.author.id, 0, 0)
result = cursor.fetchall()
await tendant.channel.send(result)
cursor.execute(sqlupdate, val)
db.close()
bot.run(token)
Upvotes: 0
Views: 760
Reputation:
You need to commit
your changes:
async def open_account(tendant):
db = sqlite3.connect('leveling.sqlite')
cursor = db.cursor()
val = (tendant.author.id, 0, 0)
cursor.execute('INSERT INTO leveling (user_id, xp, local_xp) VALUES(?, ?, ?)', val)
# Save (commit) the changes
db.commit()
# We can close the connection if we are done with it.
# Just be sure any changes have been committed or they will be lost.
db.close()
See: https://docs.python.org/3/library/sqlite3.html
Upvotes: 3