Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine Mysql connection ID in Perl?

Tags:

mysql

perl

dbi

I am trying to understand, do my modules share DBI connection to MySQL or no. I'd like to determine their connection ID. There may be better solutions (and i'd like to know them), but first question is still about knowing connection ID.

like image 694
w.k Avatar asked Dec 21 '22 05:12

w.k


2 Answers

You can use the CONNECTION_ID function, e.g.:

my ($id) = $dbh->selectrow_array('SELECT CONNECTION_ID()');
like image 71
Eugene Yarmash Avatar answered Dec 30 '22 00:12

Eugene Yarmash


You can try this too, as you're mentioning MySQL

my $threadId = $dbmyh->{ q{mysql_thread_id} };

From DBD::mysql documentation

like image 33
TVNshack Avatar answered Dec 30 '22 00:12

TVNshack