Thank you very much, seems to work as I wanted. By the way, you are using executor=function in create_engine. I do not see it in the documentation [1]. Is it just missing in the docs or it is a private parameter?
Regards, Stefan [1] http://docs.sqlalchemy.org/en/latest/core/engines.html#sqlalchemy.create_engine On 24.4.2012, at 9:50, Robert Forkel wrote: > 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 > <[email protected]> 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 [email protected]. >> 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. > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To post to this group, send email to [email protected]. > 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. > Stefan Urbanek data analyst and data brewmaster Twitter: @Stiivi Home: http://stiivi.com Brewery: http://databrewery.org Github: https://github.com/Stiivi -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [email protected]. 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.
