On Sep 1, 2011, at 5:39 PM, Arthur Kopatsy wrote:

> Hi,
> 
> We are using postgresql with Slony set up for replication. The trick
> is that all DDL changes must go through Slony (http://slony.info/
> documentation/1.2/ddlchanges.html) that way:
>   EXECUTE SCRIPT (
>   FILENAME = 'path to a sql script'
> )
> 
> Since, I still want to leverage sqlalchemy for my migration, I was
> thinking about modifyin the engine/dialect to intercept these DROP/
> CREATE/ALTER commands, dump them into a temporary file and call
> EXECUTE SCRIPT on it instead of passing them directly to the
> connection.
> 
> My questions are:
> 1. Does that solution make sense or are there other options?
> 2. At what layer can I do such a change?

I don't know much about Slony but absolutely intercepting the engine is how to 
go about dumping DDL into a file.

The recipe for doing this is at:

http://www.sqlalchemy.org/trac/wiki/FAQ#HowcanIgettheCREATETABLEDROPTABLEoutputasastring

def dump(sql, *multiparams, **params):
    print sql.compile(dialect=engine.dialect)
engine = create_engine('postgresql://', strategy='mock', executor=dump)
metadata.create_all(engine, checkfirst=False)





> 
> Thanks for your help,
> 
> Arthur
> 
> -- 
> 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.
> 

-- 
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