w.k
w.k

Reputation: 8376

How to determine Mysql connection ID in Perl?

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.

Upvotes: 4

Views: 854

Answers (2)

TVNshack
TVNshack

Reputation: 107

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

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

From DBD::mysql documentation

Upvotes: 1

Eugene Yarmash
Eugene Yarmash

Reputation: 149823

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

my ($id) = $dbh->selectrow_array('SELECT CONNECTION_ID()');

Upvotes: 10

Related Questions