Pymysql opens debug mode

Time:2019-10-24

Today in the troubleshooting line a strange database connection problem, so open pymysql source code in reading, found pymysql in itsconnectionsOne is built into the moduleDEBUGVariable to control whether debugging mode is enabled, and if so, the operation of the current connection and the contents of the message are printed to the console.

Method of use

In your server initialization code, add a pairDEBUG, such as:

import pymysql
pymysql.install_as_MySQLdb()
Pymysql. Connections. The DEBUG = True # this is my new line

After restarting the server and accessing the relevant interface, you will see some output similar to the following in the standard output:

Pymysql opens debug mode