I have made a simple CRUD database program like a very simple inventory system. It is able to read from database, update the database, delete things from database and etc. by doing queries to the SQLite3 database. Now, I would like to make it executable so that I could share it to users for them to try out the program.
By now, I have tried pyinstaller with such code:
pyinstaller --onefile --add-data "database.db:." inventory.py
It successfully compiled the program. However, when I execute the executable file, comes an error in the terminal saying sqlite3.OperationalError: no such table: items_list and it immediately close the program.
Here is the code inside the program for me to connect to the sqlite3 database:
db = sqlite3.connect('database.db')
cursor = db.cursor()
and for me to display the items in the treeview, I used:
def update(rows):
tree.delete(*tree.get_children())
for i in rows:
tree.insert('', 'end', value=i)
...
query = 'SELECT ItemName, CardNo, StockCount FROM items_list'
cursor.execute(query)
rows = cursor.fetchall()
update(rows)
Is there a way where I could combine the .py file with the .db file and make an executable single program? Thank you very much in advance for your help!