JackTheRussel
Programmer
Hi!
I have application where my connection parameters are written into code
Now I would like to hide my connection parameters into connection.ini file and I have try this kind of solution, but it dosent work:
connection.ini
And I have try to connect into database like this:
And I have write references to the connection.ini file, but
I get error message: Can't connect to data source , no database driver specified and DBI_DSN env var not set at xxx/xxx/xxx
DBI::connect('DBI', 'undef', 'undef', 'undef') called at /xxxx/xxx/xx...
Could some one help me?
I have application where my connection parameters are written into code
Code:
my $database_host = 'localhost';
my $database_name = 'MyDatabase';
my $database_username = 'root';
my $database_password = 'Password';
my $dsn = 'DBI:mysql:'.$db_name.':'.$db_host;
Now I would like to hide my connection parameters into connection.ini file and I have try this kind of solution, but it dosent work:
connection.ini
Code:
[DataBaseParameters]
database_host = localhost
database_name = MyDatabase
database_username = root
database_password = Password
dsn = DBI:mysql
And I have try to connect into database like this:
Code:
my $database_connection = DBI->connect($database_options{"dsn"}$database_options{"database_username"},
$database_options{"database_password"},$database_options{"database_localhost"},$database_options{"database_name"});
And I have write references to the connection.ini file, but
I get error message: Can't connect to data source , no database driver specified and DBI_DSN env var not set at xxx/xxx/xxx
DBI::connect('DBI', 'undef', 'undef', 'undef') called at /xxxx/xxx/xx...
Could some one help me?