On Jan 30, 2014, at 9:52 PM, Lucas Taylor <ltaylor.vo...@gmail.com> wrote:
> Any notion of how one might instruct SQLAlchemy to (conditionally) create > tables using UNLOGGED? > > I'd like to be able to modify the DDL for all CREATE TABLE statements under > certain conditions (dialect=postgresql & testing=True) > If not under test, then there would be no need to modify CREATE TABLE. > > I'm thinking that it might involve some kind of before_create event and > modifying the DDL, e.g. something that might start like: > > event.listen( > metadata, > 'before_create', > DDL('CREATE UNLOGGED TABLE').execute_if(dialect='postgresql', > callable_=isUnderTest, state=TESTING) > > Does this seem like the right direction? sorta, though you might also look into using @compiles on top of sqlalchemy.schema.CreateTable, see http://docs.sqlalchemy.org/en/rel_0_9/core/compiler.html.
signature.asc
Description: Message signed with OpenPGP using GPGMail