Hermann Himmelbauer wrote:
> Hi,
> Is there a simple way to display the create statements of SA Tables? If I do 
> a 
> my_table.create(), some SQL is created and executed, is there a way to find 
> retrieve this as a string without creating the table?
>
> Best Regards,
> Hermann
>   

When you instantiate an engine with create_engine there is an option 
'echo' which echos the SQL.

 >>> from sqlalchemy import *
 >>> engine = create_engine('sqlite://', echo=True)
 >>> metadata = MetaData(engine)
 >>> a_table = Table('name', metadata,
...     Column('id', Integer, primary_key=True))
 >>> a_table.create()
2008-07-09 08:38:16,682 INFO sqlalchemy.engine.base.Engine.0x..cL
CREATE TABLE name (
        id INTEGER NOT NULL,
        PRIMARY KEY (id)
)


2008-07-09 08:38:16,682 INFO sqlalchemy.engine.base.Engine.0x..cL {}
2008-07-09 08:38:16,684 INFO sqlalchemy.engine.base.Engine.0x..cL COMMIT
 >>>
--
Andrew


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to