Hey there -
we have the usual slate of answers, I know you've used SQLAlchemy for a long time so these should be familiar:
1. make your own function (easiest)
def tablespace_index(*arg, **kw):
kw["postgresql_tablespace"] = "my_tablespace"
return Index(*arg, **kw)
2. intercept DDL at the Python construction level (probably the smoothest approach, you can look at "parent" to check the Table)
@event.listens_for(Index, "before_parent_attach")
def before_parent_attach(target, parent):
target.dialect_kwargs["postgresql_tablespace"] = "my_tablespace"
3. intercept DDL at the SQL execution level (heavy handed)
@event.listens_for(connection, "before_execute")
def before_execute(elem, clauseelement, multiparams, params, execution_options):
if isinstance(clauseelement, CreateIndex):
clauseelement.element.dialect_kwargs["postgresql_tablespace"] = "my_tablespace"
that's what I got for this one.
Thank You
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
---
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.