【发布时间】:2015-09-02 08:23:42
【问题描述】:
这是当前为 JSONB 创建索引的代码。
Index("mytable_data_idx_id_key", Mytable.data['id'].astext, postgresql_using='gin')
但是我收到了这个错误。
sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) data type text has no default operator class for access method "gin"
HINT: You must specify an operator class for the index or define a default operator class for the data type.
[SQL: "CREATE INDEX event_data_idx_id_key ON event USING gin ((data ->> 'id'))"]
有没有办法在 SQLAlchemy 上创建索引?
【问题讨论】:
标签: python postgresql indexing sqlalchemy