Hi all
I am giving Pylons a try with SQLAlchemy, and I love it, there is just one thing, is it possible to print out the raw SQL CREATE TABLE data generated from Table().create() before it's executed?
Hi all
I am giving Pylons a try with SQLAlchemy, and I love it, there is just one thing, is it possible to print out the raw SQL CREATE TABLE data generated from Table().create() before it's executed?
SQLAlchemy is designed in such a way that doesn't allow echoing generated DDL statements without actually executing them. AFAIK, SQLAlchemy Migrate use mock engine to catch statements without executing when --preview_sql option is used, so using it is one way to solve your problem.
Something like this?
http://www.sqlalchemy.org/trac/wiki/FAQ#HowcanIgettheCREATETABLEDROPTABLEoutputasastring
from sqlalchemy.schema import CreateTable
print CreateTable(table)
If you are using declarative syntax:
print CreateTable(Model.__table__)