Re: [sqlalchemy] almbic postgres text_pattern_ops on index
On Thu, Jan 18, 2018 at 1:35 PM, kriswrote: > > > Try to create a postgres specific option while creating index , pointer > appreciated > > this link > http://alembic.zzzcomputing.com/en/latest/ops.html#alembic.operations.Operations.create_index > suggest I can pass dialect specific options > > def upgrade(): > op.drop_index('ix_taggable_resource_value', 'taggable') > op.create_index('ix_taggable_resource_value', 'taggable', [ > 'resource_value' ], > postgresql_ops = { 'resource_value', 'text_pattern_ops' > } ) postgresql_ops should be a dictionary, not a set > > > NFO [alembic.migration] Running upgrade 2cbd9f4d11af -> 318381ec60ba, > indexes 4 deletes > Traceback (most recent call last): > File "/home/kgk/Envs/bq059/bin/alembic", line 11, in > sys.exit(main()) > File > "/home/kgk/Envs/bq059/local/lib/python2.7/site-packages/alembic/config.py", > line 298, in main > CommandLine(prog=prog).main(argv=argv) > File > "/home/kgk/Envs/bq059/local/lib/python2.7/site-packages/alembic/config.py", > line 293, in main > self.run_cmd(cfg, options) > File > "/home/kgk/Envs/bq059/local/lib/python2.7/site-packages/alembic/config.py", > line 279, in run_cmd > **dict((k, getattr(options, k)) for k in kwarg) > File > "/home/kgk/Envs/bq059/local/lib/python2.7/site-packages/alembic/command.py", > line 124, in upgrade > script.run_env() > File > "/home/kgk/Envs/bq059/local/lib/python2.7/site-packages/alembic/script.py", > line 199, in run_env > util.load_python_file(self.dir, 'env.py') > File > "/home/kgk/Envs/bq059/local/lib/python2.7/site-packages/alembic/util.py", > line 205, in load_python_file > module = load_module_py(module_id, path) > File > "/home/kgk/Envs/bq059/local/lib/python2.7/site-packages/alembic/compat.py", > line 58, in load_module_py > mod = imp.load_source(module_id, path, fp) > File "./migrations/env.py", line 76, in > run_migrations_online() > File "./migrations/env.py", line 69, in run_migrations_online > context.run_migrations() > File "", line 7, in run_migrations > File > "/home/kgk/Envs/bq059/local/lib/python2.7/site-packages/alembic/environment.py", > line 681, in run_migrations > self.get_context().run_migrations(**kw) > File > "/home/kgk/Envs/bq059/local/lib/python2.7/site-packages/alembic/migration.py", > line 225, in run_migrations > change(**kw) > File "./migrations/versions/318381ec60ba_indexes_4_deletes.py", line 22, > in upgrade > postgresql_ops = { 'resource_value', 'text_pattern_ops' } ) > File "", line 7, in create_index > File > "/home/kgk/Envs/bq059/local/lib/python2.7/site-packages/alembic/operations.py", > line 698, in create_index > self._index(name, table_name, columns, schema=schema, **kw) > File > "/home/kgk/Envs/bq059/local/lib/python2.7/site-packages/alembic/ddl/impl.py", > line 161, in create_index > self._exec(schema.CreateIndex(index)) > File > "/home/kgk/Envs/bq059/local/lib/python2.7/site-packages/alembic/ddl/impl.py", > line 76, in _exec > conn.execute(construct, *multiparams, **params) > File > "/home/kgk/Envs/bq059/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", > line 945, in execute > return meth(self, multiparams, params) > File > "/home/kgk/Envs/bq059/local/lib/python2.7/site-packages/sqlalchemy/sql/ddl.py", > line 68, in _execute_on_connection > return connection._execute_ddl(self, multiparams, params) > File > "/home/kgk/Envs/bq059/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", > line 996, in _execute_ddl > if not self.schema_for_object.is_default else None) > File "", line 1, in > File > "/home/kgk/Envs/bq059/local/lib/python2.7/site-packages/sqlalchemy/sql/elements.py", > line 436, in compile > return self._compiler(dialect, bind=bind, **kw) > File > "/home/kgk/Envs/bq059/local/lib/python2.7/site-packages/sqlalchemy/sql/ddl.py", > line 26, in _compiler > return dialect.ddl_compiler(dialect, self, **kw) > File > "/home/kgk/Envs/bq059/local/lib/python2.7/site-packages/sqlalchemy/sql/compiler.py", > line 216, in __init__ > self.string = self.process(self.statement, **compile_kwargs) > File > "/home/kgk/Envs/bq059/local/lib/python2.7/site-packages/sqlalchemy/sql/compiler.py", > line 242, in process > return obj._compiler_dispatch(self, **kwargs) > File > "/home/kgk/Envs/bq059/local/lib/python2.7/site-packages/sqlalchemy/sql/visitors.py", > line 81, in _compiler_dispatch > return meth(self, **kw) > File > "/home/kgk/Envs/bq059/local/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.py", > line 1670, in visit_create_index > for expr in index.expressions > TypeError: 'set' object has no attribute '__getitem__' > An Unknown exception occured There was a problem initializing the Database > > -- > SQLAlchemy - > The Python SQL Toolkit and Object Relational Mapper > > http://www.sqlalchemy.org/ > > To post example code,
[sqlalchemy] almbic postgres text_pattern_ops on index
Try to create a postgres specific option while creating index , pointer appreciated this link http://alembic.zzzcomputing.com/en/latest/ops.html#alembic.operations.Operations.create_index suggest I can pass dialect specific options def upgrade(): op.drop_index('ix_taggable_resource_value', 'taggable') op.create_index('ix_taggable_resource_value', 'taggable', [ 'resource_value' ], postgresql_ops = { 'resource_value', 'text_pattern_ops' } ) NFO [alembic.migration] Running upgrade 2cbd9f4d11af -> 318381ec60ba, indexes 4 deletes Traceback (most recent call last): File "/home/kgk/Envs/bq059/bin/alembic", line 11, in sys.exit(main()) File "/home/kgk/Envs/bq059/local/lib/python2.7/site-packages/alembic/config.py", line 298, in main CommandLine(prog=prog).main(argv=argv) File "/home/kgk/Envs/bq059/local/lib/python2.7/site-packages/alembic/config.py", line 293, in main self.run_cmd(cfg, options) File "/home/kgk/Envs/bq059/local/lib/python2.7/site-packages/alembic/config.py", line 279, in run_cmd **dict((k, getattr(options, k)) for k in kwarg) File "/home/kgk/Envs/bq059/local/lib/python2.7/site-packages/alembic/command.py", line 124, in upgrade script.run_env() File "/home/kgk/Envs/bq059/local/lib/python2.7/site-packages/alembic/script.py", line 199, in run_env util.load_python_file(self.dir, 'env.py') File "/home/kgk/Envs/bq059/local/lib/python2.7/site-packages/alembic/util.py", line 205, in load_python_file module = load_module_py(module_id, path) File "/home/kgk/Envs/bq059/local/lib/python2.7/site-packages/alembic/compat.py", line 58, in load_module_py mod = imp.load_source(module_id, path, fp) File "./migrations/env.py", line 76, in run_migrations_online() File "./migrations/env.py", line 69, in run_migrations_online context.run_migrations() File "", line 7, in run_migrations File "/home/kgk/Envs/bq059/local/lib/python2.7/site-packages/alembic/environment.py", line 681, in run_migrations self.get_context().run_migrations(**kw) File "/home/kgk/Envs/bq059/local/lib/python2.7/site-packages/alembic/migration.py", line 225, in run_migrations change(**kw) File "./migrations/versions/318381ec60ba_indexes_4_deletes.py", line 22, in upgrade postgresql_ops = { 'resource_value', 'text_pattern_ops' } ) File "", line 7, in create_index File "/home/kgk/Envs/bq059/local/lib/python2.7/site-packages/alembic/operations.py", line 698, in create_index self._index(name, table_name, columns, schema=schema, **kw) File "/home/kgk/Envs/bq059/local/lib/python2.7/site-packages/alembic/ddl/impl.py", line 161, in create_index self._exec(schema.CreateIndex(index)) File "/home/kgk/Envs/bq059/local/lib/python2.7/site-packages/alembic/ddl/impl.py", line 76, in _exec conn.execute(construct, *multiparams, **params) File "/home/kgk/Envs/bq059/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 945, in execute return meth(self, multiparams, params) File "/home/kgk/Envs/bq059/local/lib/python2.7/site-packages/sqlalchemy/sql/ddl.py", line 68, in _execute_on_connection return connection._execute_ddl(self, multiparams, params) File "/home/kgk/Envs/bq059/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 996, in _execute_ddl if not self.schema_for_object.is_default else None) File "", line 1, in File "/home/kgk/Envs/bq059/local/lib/python2.7/site-packages/sqlalchemy/sql/elements.py", line 436, in compile return self._compiler(dialect, bind=bind, **kw) File "/home/kgk/Envs/bq059/local/lib/python2.7/site-packages/sqlalchemy/sql/ddl.py", line 26, in _compiler return dialect.ddl_compiler(dialect, self, **kw) File "/home/kgk/Envs/bq059/local/lib/python2.7/site-packages/sqlalchemy/sql/compiler.py", line 216, in __init__ self.string = self.process(self.statement, **compile_kwargs) File "/home/kgk/Envs/bq059/local/lib/python2.7/site-packages/sqlalchemy/sql/compiler.py", line 242, in process return obj._compiler_dispatch(self, **kwargs) File "/home/kgk/Envs/bq059/local/lib/python2.7/site-packages/sqlalchemy/sql/visitors.py", line 81, in _compiler_dispatch return meth(self, **kw) File "/home/kgk/Envs/bq059/local/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.py", line 1670, in visit_create_index for expr in index.expressions TypeError: 'set' object has no attribute '__getitem__' An Unknown exception occured There was a problem initializing the Database -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- 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,