Think about Loose Coupling | |
PerlMonks |
Solved: DBI and MySQL not setting database properlyby KolassaRaptor (Monk) |
on Feb 24, 2016 at 16:48 UTC ( [id://1156034]=perlquestion: print w/replies, xml ) | Need Help?? |
KolassaRaptor has asked for the wisdom of the Perl Monks concerning the following question: My fellow Perl Monks, I've come across an issue with using DBI/DBD::mysql when connecting to a remote MySQL database. I can achieve the connection and query it just fine, however it seems that when I connect to a remote host I am required to specify the tables in my statements in the 'database.table' format instead of being able to shorthand it to just 'table' like all the documentation would lead me to believe was possible (per examples in DBD::mysql). As an example of my connection code...
Again, I am able to connect and query the database just fine, but if I do not prepend the database name to the table in my SQL statements, it will return an error. An example SQL statement...
The database will return the following...
All I have to change to make it work is prepending "$database." to my table 'group'. If I check the dbh attribute Name, it will return the entire dsn minus the 'dbi:mysql:' at the front of it. I have even tried doing a $dbh->do("USE $database;") on the connection, but it still requires me to prepend the database name to my table names in my SQL statements. Is this expected behavior?
Back to
Seekers of Perl Wisdom
|
|