MySQL Connector/Python Developer Guide

10.2.40 MySQLConnection.connection_id Property

This property returns the integer connection ID (thread ID or session ID) for the current connection or None when not connected.