echo=true with hide_parameters=false not working
See original GitHub issueDescribe the bug
I am trying to use sqa.create_engine(conn, echo=True, hide_parameters=False)
to log queries with actual parameter values, but it looks like the parameters are not being replaced.
To Reproduce
import sqlalchemy as sqa
echo_engine = sqa.create_engine(
"postgresql://localhost/postgres",
echo=True,
hide_parameters=False
)
echo_engine.execute(sqa.text("select :some_private_name"), {"some_private_name": "1"})
Error
2021-01-19 19:23:07,829 INFO sqlalchemy.engine.base.Engine select version()
2021-01-19 19:23:07,829 INFO sqlalchemy.engine.base.Engine {}
2021-01-19 19:23:07,832 INFO sqlalchemy.engine.base.Engine select current_schema()
2021-01-19 19:23:07,833 INFO sqlalchemy.engine.base.Engine {}
2021-01-19 19:23:07,840 INFO sqlalchemy.engine.base.Engine SELECT CAST('test plain returns' AS VARCHAR(60)) AS anon_1
2021-01-19 19:23:07,840 INFO sqlalchemy.engine.base.Engine {}
2021-01-19 19:23:07,844 INFO sqlalchemy.engine.base.Engine SELECT CAST('test unicode returns' AS VARCHAR(60)) AS anon_1
2021-01-19 19:23:07,844 INFO sqlalchemy.engine.base.Engine {}
2021-01-19 19:23:07,845 INFO sqlalchemy.engine.base.Engine show standard_conforming_strings
2021-01-19 19:23:07,845 INFO sqlalchemy.engine.base.Engine {}
2021-01-19 19:23:07,847 INFO sqlalchemy.engine.base.Engine select %(some_private_name)s
2021-01-19 19:23:07,847 INFO sqlalchemy.engine.base.Engine {'some_private_name': '1'}
I would expect select %(some_private_name)s
to be select 1
Versions.
- OS: MacOS BigSur
- Python: python3.8
- SQLAlchemy: 1.3.22
- Database: postgresql
- DBAPI: postgresql://
Have a nice day!
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How to show code but hide output in RMarkdown?
This echo=True, include=FALSE here does not work: the whole thing is hidden (which is the normal behavior of include=FALSE ).
Read more >Execution Options - Quarto
Include the results of executing the code in the output ( true , false , or asis to indicate that the output is...
Read more >Use runtime and type-safe parameters - Azure Pipelines
In this article. Use parameters in pipelines; Use conditionals with parameters; Parameter data types; FAQ. Azure DevOps Services | Azure ...
Read more >Parameters - AWS CloudFormation
Use parameters to pass values to your template when creating or updating a stack so that you can customize each stack deployment.
Read more >2.6 R code chunks and inline R code | R Markdown - Bookdown
When you are trying to set echo = FALSE , results = 'hide' , warning = FALSE , and ... However, I want...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
oh I see you used a psycopg2 object that gives you the parameters embedded. That’s not something that would be available for any other backend, but that’s handy, nice job!
So I ended up passing a logger at the DBAPI level by building the connection object on the
do_connect
event handler.Thank you for you help understanding this matter!