Sqlite cannot find DB file with Mojolicious and Par Packer

I am writing a program with Perl that uses Mojolicious and Sqlite. I will use Par Packer to distribute it as an .exe file for deployment on other Windows machines.

I am using Strawberry Perl for Windows for development.

I use the following windows batch file with Par Packer to generate the .exe file:

pp -o hallo.exe ^ -x ^ -l libeay32__.dll ^ -l zlib1__.dll ^ -l ssleay32__.dll ^ -a lib ^ -a public ^ -a templates ^ -a "C:\strawberry\perl\site\lib\Mojo\entities.txt;Mojo\entities.txt" ^ -a "C:\Strawberry\perl\vendor\lib\Mojolicious\resources\public;Mojolicious\public" ^ -a "C:\Strawberry\perl\vendor\lib\Mojolicious\resources\templates;Mojolicious\templates" ^ -a "D:\Perl\main.db" ^ hallo.cgi 

This works fine, but as soon as I cite SQLite, I got the following error when trying to run hello.exe: DBD :: SQLite :: db error: there is no such table: libraries

hallo.cgi works great during normal operation. For example, perl hallo.cgi. But when everything is compiled into a .exe file, a Sqlite error occurs.

What happens is that main.db (the SQL Lite database file) is in the same place as hallo.cgi (or hallo.exe), but when I run hallo.exe SQLite cannot find main.db and thus creates main.db on it, but since he created it on his own, there is no data in the database since he cannot find the library table.

How do I solve this problem?

In the batch file above, which I use to compile, I include main.db for Par Packer, but it seems to completely ignore the line:

 -a "D:\Perl\main.db" ^ 

UPDATE: I seem to have solved this by looking at what $ ENV {PWD} is. ($ ENV {PWD} indicates the working directory) and using chdir to change it. After that, SQlite was able to get the file and work properly. Please note that in my source code I have operations that include the libraries and modules needed for the Par package, which created a situation where the working directory changed. This has been changed to the original working directory.

+5
source share

All Articles