Python Forum
.py to .exe question using PyInstaller
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
.py to .exe question using PyInstaller
#1
Does PyInstaller allow the inclusion of the Data Base i am using for deployment purposes, or should i just include a copy of the DB in the same folder as the .exe?
I imported SQLite3 and started to build the SQLite DB with code in the program and got lazy. Used a DB Browser instead to create all the tables outside code.
Suggestions?
Reply
#2
Use a spec file

https://pyinstaller.readthedocs.io/en/st...files.html
Reply
#3
The database file should not be included in the bundle. This will work ONLY if it will be read-only and still I will provide it along the exe, not in the bundle.
If you plan to write/update data, how do you gonna preserve changes in the database?

either provide the db file along the exe (e.g. with installer or create on first run) or you can create run-time hook, see, e.g. https://stackoverflow.com/questions/3383...le-onefile
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#4
Thanks for the resources above.
To test my understanding; if i am creating a one-folder bundle and use either --add--data or datas (script) to bundle the existing DataBase, my insert/delete/update's will not commit changes?

So-if true, if i create the one-folder bundle without the DB; can i copy and paste the DB into this folder after PyInstaller creates it? Will the compiled App find the DB like it is doing now-in same folder? If so, i can share it to get some early feedback.

If not, sounds like i might as well code it into my App to create the DB and tables the first time the App is ran?
Is the latter the typical way it is handled?
Reply
#5
(Feb-18-2022, 02:30 PM)hammer Wrote: if i am creating a one-folder bundle
Maybe I misunderstood this
(Feb-18-2022, 01:59 AM)hammer Wrote: Does PyInstaller allow the inclusion of the Data Base i am using for deployment purposes, or should i just include a copy of the DB in the same folder as the .exe?
My understanding was that you are creating one-file bundle

Read Run-time Information section of the docs which explains how you can know which path to use, i.e. to executable, or to the bundle, etc.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#6
Thanks for the direction-i will.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  PyInstaller related question Evil_Patrick 6 2,926 Jul-18-2020, 07:59 AM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020