Forums

discord.app_commands.errors.CommandInvokeError: Command 'balance' raised an exception: OperationalError: no such table: users#033[0m

I keep getting this error when I run a file as an always on task. But then when I run the file through my files tab and open it, it runs fine. Why is this? Again its only with always on task.

It looks like it can't find your database. You can try using an absolute path to access it.

Where can I find this absolute path to my database?

How do you connect to it from your code?

I just use conn = sqlite3.connect("discord.db") discord.db being the database file.

Okay so when you give it the filename 'discord.db' it will look for the database in whatever directory you're running the script from. You have two options: change the working directory in the always on command eg cd /home/jadenbon/some/dir && python3.11 your_script.py, or provide an absolute path to sqlite3.connect eg /home/jadenbon/mysite/appdir/discord.db

If youre still unsure about the absolute path, if you head to a bash console and go to the directory where the database file is located and run pwd (print working directory)