1

I am developing a program in Python that reads text files containing SQL queries. To generate the .exe, I am using Pyinstaller with the --onefile option. The problem is that whenever I run this executable, it does not work if it is not in the same folder as the Queries folder. I wish to distribute this .exe by itself without the Queries folder, so I need some way to include this folder within the executable.

I tried editing the .spec file as in the solution in this link, but it seems like I am not really understanding it as I cannot manage it work. Upon further searching, I have not been able to sovle this problem.

Any help will be much appreciated!

Community
  • 1
  • 1
Diego St
  • 59
  • 9

2 Answers2

1

A quick option, could be creating a python module out of your queries. myQueries.py:

query_1 = """Select * from foo"""
query_2 = """Select * from bar"""

Then you can import it in your program:

import myQueries
db.execute(myQueries.query_1)
...
Maurice Meyer
  • 17,279
  • 4
  • 30
  • 47
  • Hello! You are absolutely right, that is indeed an option that would work. Nonetheless, I cannot implement it due to the fact that the source code must be passed on to people without programming background, which means that keeping the separate files makes the program much more readble and easier to edit for them. Thank you very much! – Diego St Jan 06 '17 at 15:29
0

The answers to this issuee was a combination of the answers provided in this question and this other question

Community
  • 1
  • 1
Diego St
  • 59
  • 9