Created
December 10, 2014 15:07
Print a literal SQLAlchemy statement
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print(str(select.compile(engine, compile_kwargs={'literal_binds': True})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is only useful for testing select statements if, for instance, it's difficult to connect to a database in your development environment. Under no circumstances should you use this in production as you're opening yourself to SQL injection attacks one of the things binding protects against. Here we're directing sqlalchemy to literally bind values during statement compilation.