Thank you monks. I have tried any possible solution (cleaning the path for Windows, setting ENV etc.), but NO solution works in the packed versions (pp). And I really do not understand why! Here is a better script that reproduces the problem (the first part works, the second no).
use warnings; use strict; use DBI; use DBD::SQLite; #Working part with hard coded path my $dbfile1="C:/users/DON/Desktop/data.db"; print "\nFIRST Connection to dbfile path read from script ($dbfile1) . +.. "; my $dbh = DBI->connect("dbi:SQLite:dbname=$dbfile1","","") || die $DBI +::errstr; print "done!\n\n"; #NOT working part with path from file my $dbfile2; print "Reading dbfile path from configuration file... "; my $FileInput="config.txt";#simple txt file containing this: C:/users/ +DON/Desktop/data.db open my $FH, "<:encoding(UTF-8)", $FileInput || die (print "can't open + file $dbfile2"); while (my $line = <$FH>) { $dbfile2 = $line; chomp $dbfile2; } print "$dbfile2\n"; print "SECOND Connection with dbfile read from file $dbfile2 ... "; $dbh = DBI->connect("dbi:SQLite:dbname=$dbfile2","","")|| die $DBI::er +rstr; print "done!\n";
Again, from the command line the script works correctly. The by pp compiled version behaves like this:
IFIRST Connection to dbfile path read from script (C:/users/DON/Desktop +/data.db) ... done! Reading dbfile path from configuration file... C:/users/DON/Desktop/da +ta.db Can't connect to data source 'dbi:SQLite:dbname=C:/users/DON/Desktop/d +ata.db' because I can't work out what driver to use (it doesn't seem +to contain a 'dbi:driver:' prefix and the DBI_DRIVER env var is not s +et) at script/myscript.pl line 22. SECOND Connection with dbfile read from file C:/users/DON/Desktop/data +.db ...
I've been stuck for days on this problem. So any help is very much appreciated
In reply to Re^2: Can't connect to data source 'DBI:SQLite:\C:\Users\DON\Desktop\data.db
by IB2017
in thread pp concatenate path
by IB2017
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |