Given that what you want makes sense only when debugging, you could start SQLAlchemy with echo=True, to log all SQL queries. For example:
engine = create_engine(
"mysql://scott:tiger@hostname/dbname",
encoding="latin1",
echo=True,
)
This can also be modified for just a single request:
echo=False– ifTrue, the Engine will log all statements as well as arepr()of their parameter lists to the engines logger, which defaults tosys.stdout. Theechoattribute ofEnginecan be modified at any time to turn logging on and off. If set to the string"debug", result rows will be printed to the standard output as well. This flag ultimately controls a Python logger; see Configuring Logging for information on how to configure logging directly.
Source: SQLAlchemy Engine Configuration
If used with Flask, you can simply set
app.config["SQLALCHEMY_ECHO"] = True
to get the same behaviour.
Given that what you want makes sense only when debugging, you could start SQLAlchemy with echo=True, to log all SQL queries. For example:
engine = create_engine(
"mysql://scott:tiger@hostname/dbname",
encoding="latin1",
echo=True,
)
This can also be modified for just a single request:
echo=False– ifTrue, the Engine will log all statements as well as arepr()of their parameter lists to the engines logger, which defaults tosys.stdout. Theechoattribute ofEnginecan be modified at any time to turn logging on and off. If set to the string"debug", result rows will be printed to the standard output as well. This flag ultimately controls a Python logger; see Configuring Logging for information on how to configure logging directly.
Source: SQLAlchemy Engine Configuration
If used with Flask, you can simply set
app.config["SQLALCHEMY_ECHO"] = True
to get the same behaviour.
Given that what you want makes sense only when debugging, you could start SQLAlchemy with echo=True, to log all SQL queries. For example:
engine = create_engine(
"mysql://scott:tiger@hostname/dbname",
encoding="latin1",
echo=True,
)
This can also be modified for just a single request:
echo=False– ifTrue, the Engine will log all statements as well as arepr()of their parameter lists to the engines logger, which defaults tosys.stdout. Theechoattribute ofEnginecan be modified at any time to turn logging on and off. If set to the string"debug", result rows will be printed to the standard output as well. This flag ultimately controls a Python logger; see Configuring Logging for information on how to configure logging directly.Source: SQLAlchemy Engine Configuration
If used with Flask, you can simply set
app.config["SQLALCHEMY_ECHO"] = True
to get the same behaviour.
Given that what you want makes sense only when debugging, you could start SQLAlchemy with echo=True, to log all SQL queries. For example:
engine = create_engine(
"mysql://scott:tiger@hostname/dbname",
encoding="latin1",
echo=True,
)
This can also be modified for just a single request:
echo=False– ifTrue, the Engine will log all statements as well as arepr()of their parameter lists to the engines logger, which defaults tosys.stdout. Theechoattribute ofEnginecan be modified at any time to turn logging on and off. If set to the string"debug", result rows will be printed to the standard output as well. This flag ultimately controls a Python logger; see Configuring Logging for information on how to configure logging directly.
Source: SQLAlchemy Engine Configuration
If used with Flask, you can simply set
app.config["SQLALCHEMY_ECHO"] = True
to get the same behaviour.