enable SQL statements echo with SQLALCHEMY_ECHO config constant for debugging (#1369)
This commit is contained in:
parent
bfec196d84
commit
23fa6d5ec4
@ -124,6 +124,8 @@ RUN_BACKEND_PROD_WINDOWS = f"uvicorn --timeout-keep-alive {TIMEOUT}".split()
|
|||||||
# Socket.IO web server
|
# Socket.IO web server
|
||||||
PING_INTERVAL = 25
|
PING_INTERVAL = 25
|
||||||
PING_TIMEOUT = 120
|
PING_TIMEOUT = 120
|
||||||
|
# flag to make the engine print all the SQL statements it executes
|
||||||
|
SQLALCHEMY_ECHO = get_value("SQLALCHEMY_ECHO", False, type_=bool)
|
||||||
|
|
||||||
# Compiler variables.
|
# Compiler variables.
|
||||||
# The extension for compiled Javascript files.
|
# The extension for compiled Javascript files.
|
||||||
|
@ -40,9 +40,12 @@ def get_engine(url: Optional[str] = None):
|
|||||||
console.print(
|
console.print(
|
||||||
"[red]Database is not initialized, run [bold]reflex db init[/bold] first."
|
"[red]Database is not initialized, run [bold]reflex db init[/bold] first."
|
||||||
)
|
)
|
||||||
|
echo_db_query = False
|
||||||
|
if conf.env == constants.Env.DEV and constants.SQLALCHEMY_ECHO:
|
||||||
|
echo_db_query = True
|
||||||
return sqlmodel.create_engine(
|
return sqlmodel.create_engine(
|
||||||
url,
|
url,
|
||||||
echo=False,
|
echo=echo_db_query,
|
||||||
connect_args={"check_same_thread": False} if conf.admin_dash else {},
|
connect_args={"check_same_thread": False} if conf.admin_dash else {},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user