On Sep 1, 2014, at 4:29 AM, Lele Gaifax <[email protected]> wrote:

> Hi all,
> 
> I'd need to create a partial index on a SQLite database
> (http://www.sqlite.org/partialindex.html), but it seems that there's no
> equivalent of "postgresql_where" on the sqlite dialect.
> 
> The need arises from wanting a unique constraint on a subset of the
> dataset.
> 
> Other than properly implementing such support in the core (which I
> eventually may end trying out), is there a more immediate way to
> accomplish that?
> 
> I've read about DDL() and custom SQL constructs and that seems what I'm
> seeking for, but I failed to see the interaction with my
> declarative-based schema description.
> 
> Could you please point me in the right direction?

you can attach your DDL() to the Table like this:


class MyModel(Base):
    __tablename__ = 'foo'

    # ...


from sqlalchemy import event, DDL

@event.listens_for(MyModel.__table__, "after_create")
DDL("create index my_index...")



-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to