Re: [sqlalchemy] Postgresql - Index on a json field

2016-08-28 Thread Mike Bayer
On 08/28/2016 07:53 AM, koch...@gmail.com wrote: Hi Michael, I'm trying to adapt your answer above to declare indexes inside the __table_args__ tuple in my model class. However, when I run the alembic command to generate the migration script, the JSONB column indexes are not generated. I

Re: [sqlalchemy] Postgresql - Index on a json field

2016-08-28 Thread kochhar
Hi Michael, I'm trying to adapt your answer above to declare indexes inside the __table_args__ tuple in my model class. However, when I run the alembic command to generate the migration script, the JSONB column indexes are not generated. I posted a SO question with more details, perhaps you

Re: [sqlalchemy] Postgresql - Index on a json field

2014-07-06 Thread Phillip Aquilina
Great, thanks again for the replies and thanks for the awesome tool. On Saturday, July 5, 2014 1:28:34 PM UTC-7, Michael Bayer wrote: On 7/5/14, 3:14 PM, Phillip Aquilina wrote: I finally had a chance to try this with the inspector and quickly discovered it doesn't support

Re: [sqlalchemy] Postgresql - Index on a json field

2014-07-05 Thread Phillip Aquilina
I finally had a chance to try this with the inspector and quickly discovered it doesn't support expression-based indexes with this warning, Skipped unsupported reflection of expression-based index some_index. I can patch this out locally for my own needs but is there a bigger reason this is

Re: [sqlalchemy] Postgresql - Index on a json field

2014-07-05 Thread Mike Bayer
On 7/5/14, 3:14 PM, Phillip Aquilina wrote: I finally had a chance to try this with the inspector and quickly discovered it doesn't support expression-based indexes with this warning, Skipped unsupported reflection of expression-based index some_index. I can patch this out locally for my own

Re: [sqlalchemy] Postgresql - Index on a json field

2014-07-02 Thread Phillip Aquilina
This worked as described. Thanks again. I have a followup question. It doesn't seem like there's an analog to table.create(checkfirst=True) for an Index. I found this issue https://bitbucket.org/zzzeek/sqlalchemy/issue/527/indexcreate-should-take-checkfirst that seems to mention having this

Re: [sqlalchemy] Postgresql - Index on a json field

2014-07-02 Thread Mike Bayer
On 7/2/14, 11:38 AM, Phillip Aquilina wrote: This worked as described. Thanks again. I have a followup question. It doesn't seem like there's an analog to table.create(checkfirst=True) for an Index. I found this issue

Re: [sqlalchemy] Postgresql - Index on a json field

2014-07-02 Thread Phillip Aquilina
Perfect thanks Mike. On Wednesday, July 2, 2014 10:17:17 AM UTC-7, Michael Bayer wrote: On 7/2/14, 11:38 AM, Phillip Aquilina wrote: This worked as described. Thanks again. I have a followup question. It doesn't seem like there's an analog to table.create(checkfirst=True) for an

Re: [sqlalchemy] Postgresql - Index on a json field

2014-07-01 Thread Phillip Aquilina
Ah! I'll give that a try. Thanks Mike. On Monday, June 30, 2014 10:23:13 PM UTC-7, Michael Bayer wrote: per the SO answer, you're looking for CREATE INDEX ON publishers((info-'name'));. Either you can emit this directly as a string, or use Index, just as it states: from sqlalchemy

Re: [sqlalchemy] Postgresql - Index on a json field

2014-06-30 Thread Mike Bayer
SQLAlchemy's API allows CREATE INDEX via the Index construct: http://docs.sqlalchemy.org/en/rel_0_9/core/constraints.html?highlight=index#indexes On 6/30/14, 6:21 PM, Phillip Aquilina wrote: Using postgresql, I have a JSON type column. My understanding from their docs was that only jsonb

Re: [sqlalchemy] Postgresql - Index on a json field

2014-06-30 Thread Phillip Aquilina
Thanks for replying. I've read through that doc and I still don't see how that addresses my question. Is there somewhere in there that describes how to create an index on a json field? It seems like to me it's simple to create an index on a column but this would be creating an index on nested

Re: [sqlalchemy] Postgresql - Index on a json field

2014-06-30 Thread Mike Bayer
I'm not familiar with any other style of index for this column type. If you can show me at http://www.postgresql.org/docs/9.4/static/datatype-json.html or wherever what specific DDL you're looking for, you can simply emit it using engine.execute(ddl). On 6/30/14, 11:02 PM, Phillip Aquilina

Re: [sqlalchemy] Postgresql - Index on a json field

2014-06-30 Thread Mike Bayer
per the SO answer, you're looking for CREATE INDEX ON publishers((info-'name'));. Either you can emit this directly as a string, or use Index, just as it states: from sqlalchemy import create_engine, Integer, Index, Table, Column, MetaData from sqlalchemy.dialects.postgresql import JSON e =