what I do is using a custom engine like this:

        out = StringIO()
        def dump(sql, *multiparams, **params):
            # make sure the mock engine appends ';' to the end of DDL statements
            # so they can be pasted and run in sql developer!
            out.write(('%s' %
sql.compile(dialect=engine.dialect)).strip()+';\n/\n')
        engine = create_engine('oracle://', strategy='mock', executor=dump)

regards
robert

On Tue, Apr 24, 2012 at 9:33 AM, Stefan Urbanek
<stefan.urba...@gmail.com> wrote:
> Hi,
>
> How can I get a string that is going to be executed without executing it?
>
> Example code:
>
> from sqlalchemy import create_engine, MetaData, Table, Column, Integer,
> String
>
> engine = create_engine("sqlite://")
> metadata = MetaData(engine)
>
> table = Table("foo", metadata)
> table.append_column(Column("id", Integer))
> table.append_column(Column("name", String))
>
>
>
> Now I would like to get the "CREATE TABLE ..." string that I would like to
> store/use somewhere else.
>
> How can I do that?
>
> Thanks for any hints,
>
> Stefan
>
> --
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/sqlalchemy/-/jJTcbg44Yx8J.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> To unsubscribe from this group, send email to
> sqlalchemy+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/sqlalchemy?hl=en.

-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to