Here are the examples of the python api sqlalchemy.schema.CreateIndex taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
86 Examples
3
Source : mssql.py
with MIT License
from DiptoChakrabarty
with MIT License
from DiptoChakrabarty
def create_index(self, index):
# this likely defaults to None if not present, so get()
# should normally not return the default value. being
# defensive in any case
mssql_include = index.kwargs.get("mssql_include", None) or ()
for col in mssql_include:
if col not in index.table.c:
index.table.append_column(Column(col, sqltypes.NullType))
self._exec(CreateIndex(index))
def bulk_insert(self, table, rows, **kw):
3
Source : test_compiler.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_table_idx_explicit_nonclustered(self):
metadata = MetaData()
tbl = Table(
"test",
metadata,
Column("x", Integer, autoincrement=False),
Column("y", Integer, autoincrement=False),
)
idx = Index("myidx", tbl.c.x, tbl.c.y, mssql_clustered=False)
self.assert_compile(
schema.CreateIndex(idx),
"CREATE NONCLUSTERED INDEX myidx ON test (x, y)",
)
def test_table_uc_explicit_nonclustered(self):
3
Source : test_compiler.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_index_clustering(self):
metadata = MetaData()
tbl = Table("test", metadata, Column("id", Integer))
idx = Index("foo", tbl.c.id, mssql_clustered=True)
self.assert_compile(
schema.CreateIndex(idx), "CREATE CLUSTERED INDEX foo ON test (id)"
)
def test_index_where(self):
3
Source : test_compiler.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_index_where(self):
metadata = MetaData()
tbl = Table("test", metadata, Column("data", Integer))
idx = Index("test_idx_data_1", tbl.c.data, mssql_where=tbl.c.data > 1)
self.assert_compile(
schema.CreateIndex(idx),
"CREATE INDEX test_idx_data_1 ON test (data) WHERE data > 1",
)
def test_index_ordering(self):
3
Source : test_compiler.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_index_ordering(self):
metadata = MetaData()
tbl = Table(
"test",
metadata,
Column("x", Integer),
Column("y", Integer),
Column("z", Integer),
)
idx = Index("foo", tbl.c.x.desc(), "y")
self.assert_compile(
schema.CreateIndex(idx), "CREATE INDEX foo ON test (x DESC, y)"
)
def test_create_index_expr(self):
3
Source : test_compiler.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_create_index_expr(self):
m = MetaData()
t1 = Table("foo", m, Column("x", Integer))
self.assert_compile(
schema.CreateIndex(Index("bar", t1.c.x > 5)),
"CREATE INDEX bar ON foo (x > 5)",
)
def test_drop_index_w_schema(self):
3
Source : test_compiler.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_index_extra_include_1(self):
metadata = MetaData()
tbl = Table(
"test",
metadata,
Column("x", Integer),
Column("y", Integer),
Column("z", Integer),
)
idx = Index("foo", tbl.c.x, mssql_include=["y"])
self.assert_compile(
schema.CreateIndex(idx), "CREATE INDEX foo ON test (x) INCLUDE (y)"
)
def test_index_extra_include_2(self):
3
Source : test_compiler.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_index_extra_include_2(self):
metadata = MetaData()
tbl = Table(
"test",
metadata,
Column("x", Integer),
Column("y", Integer),
Column("z", Integer),
)
idx = Index("foo", tbl.c.x, mssql_include=[tbl.c.y])
self.assert_compile(
schema.CreateIndex(idx), "CREATE INDEX foo ON test (x) INCLUDE (y)"
)
def test_try_cast(self):
3
Source : test_compiler.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_create_index_simple(self):
m = MetaData()
tbl = Table("testtbl", m, Column("data", String(255)))
idx = Index("test_idx1", tbl.c.data)
self.assert_compile(
schema.CreateIndex(idx), "CREATE INDEX test_idx1 ON testtbl (data)"
)
def test_create_index_with_prefix(self):
3
Source : test_compiler.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_create_index_with_prefix(self):
m = MetaData()
tbl = Table("testtbl", m, Column("data", String(255)))
idx = Index(
"test_idx1", tbl.c.data, mysql_length=10, mysql_prefix="FULLTEXT"
)
self.assert_compile(
schema.CreateIndex(idx),
"CREATE FULLTEXT INDEX test_idx1 " "ON testtbl (data(10))",
)
def test_create_index_with_parser(self):
3
Source : test_compiler.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_create_index_with_parser(self):
m = MetaData()
tbl = Table("testtbl", m, Column("data", String(255)))
idx = Index(
"test_idx1",
tbl.c.data,
mysql_length=10,
mysql_prefix="FULLTEXT",
mysql_with_parser="ngram",
)
self.assert_compile(
schema.CreateIndex(idx),
"CREATE FULLTEXT INDEX test_idx1 "
"ON testtbl (data(10)) WITH PARSER ngram",
)
def test_create_index_with_length(self):
3
Source : test_compiler.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_create_index_with_length(self):
m = MetaData()
tbl = Table("testtbl", m, Column("data", String(255)))
idx1 = Index("test_idx1", tbl.c.data, mysql_length=10)
idx2 = Index("test_idx2", tbl.c.data, mysql_length=5)
self.assert_compile(
schema.CreateIndex(idx1),
"CREATE INDEX test_idx1 ON testtbl (data(10))",
)
self.assert_compile(
schema.CreateIndex(idx2),
"CREATE INDEX test_idx2 ON testtbl (data(5))",
)
def test_drop_constraint_mysql(self):
3
Source : test_compiler.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_create_index_with_length_quoted(self):
m = MetaData()
tbl = Table(
"testtbl", m, Column("some quoted data", String(255), key="s")
)
idx1 = Index("test_idx1", tbl.c.s, mysql_length=10)
self.assert_compile(
schema.CreateIndex(idx1),
"CREATE INDEX test_idx1 ON testtbl (`some quoted data`(10))",
)
def test_create_composite_index_with_length_quoted(self):
3
Source : test_compiler.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_create_index_with_using(self):
m = MetaData()
tbl = Table("testtbl", m, Column("data", String(255)))
idx1 = Index("test_idx1", tbl.c.data, mysql_using="btree")
idx2 = Index("test_idx2", tbl.c.data, mysql_using="hash")
self.assert_compile(
schema.CreateIndex(idx1),
"CREATE INDEX test_idx1 ON testtbl (data) USING btree",
)
self.assert_compile(
schema.CreateIndex(idx2),
"CREATE INDEX test_idx2 ON testtbl (data) USING hash",
)
def test_create_pk_plain(self):
3
Source : test_compiler.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_create_index_expr(self):
m = MetaData()
t1 = Table("foo", m, Column("x", Integer))
self.assert_compile(
schema.CreateIndex(Index("bar", t1.c.x > 5)),
"CREATE INDEX bar ON foo (x > 5)",
)
def test_deferrable_initially_kw_not_ignored(self):
3
Source : test_compiler.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_too_long_index(self):
exp = "ix_zyrenian_zyme_zyzzogeton_zyzzogeton_zyrenian_zyme_zyz_5cd2"
tname = "zyrenian_zyme_zyzzogeton_zyzzogeton"
cname = "zyrenian_zyme_zyzzogeton_zo"
t1 = Table(tname, MetaData(), Column(cname, Integer, index=True))
ix1 = list(t1.indexes)[0]
self.assert_compile(
schema.CreateIndex(ix1),
"CREATE INDEX %s " "ON %s (%s)" % (exp, tname, cname),
)
def test_innodb_autoincrement(self):
3
Source : test_compiler.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_create_index_alt_schema(self):
m = MetaData()
t1 = Table("foo", m, Column("x", Integer), schema="alt_schema")
self.assert_compile(
schema.CreateIndex(Index("bar", t1.c.x)),
"CREATE INDEX alt_schema.bar ON alt_schema.foo (x)",
)
def test_create_index_expr(self):
3
Source : test_compiler.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_create_index_expr(self):
m = MetaData()
t1 = Table("foo", m, Column("x", Integer))
self.assert_compile(
schema.CreateIndex(Index("bar", t1.c.x > 5)),
"CREATE INDEX bar ON foo (x > 5)",
)
def test_table_options(self):
3
Source : test_compiler.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_create_index_expr_gets_parens(self):
m = MetaData()
tbl = Table("testtbl", m, Column("x", Integer), Column("y", Integer))
idx1 = Index("test_idx1", 5 / (tbl.c.x + tbl.c.y))
self.assert_compile(
schema.CreateIndex(idx1),
"CREATE INDEX test_idx1 ON testtbl ((5 / (x + y)))",
)
def test_create_index_literals(self):
3
Source : test_compiler.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_create_index_literals(self):
m = MetaData()
tbl = Table("testtbl", m, Column("data", Integer))
idx1 = Index("test_idx1", tbl.c.data + 5)
self.assert_compile(
schema.CreateIndex(idx1),
"CREATE INDEX test_idx1 ON testtbl ((data + 5))",
)
def test_create_index_concurrently(self):
3
Source : test_compiler.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_create_index_concurrently(self):
m = MetaData()
tbl = Table("testtbl", m, Column("data", Integer))
idx1 = Index("test_idx1", tbl.c.data, postgresql_concurrently=True)
self.assert_compile(
schema.CreateIndex(idx1),
"CREATE INDEX CONCURRENTLY test_idx1 ON testtbl (data)",
)
dialect_8_1 = postgresql.dialect()
dialect_8_1._supports_create_index_concurrently = False
self.assert_compile(
schema.CreateIndex(idx1),
"CREATE INDEX test_idx1 ON testtbl (data)",
dialect=dialect_8_1,
)
def test_drop_index_concurrently(self):
3
Source : test_constraints.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_create_index_plain(self):
t = Table("t", MetaData(), Column("x", Integer))
i = Index("xyz", t.c.x)
self.assert_compile(schema.CreateIndex(i), "CREATE INDEX xyz ON t (x)")
def test_drop_index_plain_unattached(self):
3
Source : test_constraints.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_create_index_schema(self):
t = Table("t", MetaData(), Column("x", Integer), schema="foo")
i = Index("xyz", t.c.x)
self.assert_compile(
schema.CreateIndex(i), "CREATE INDEX xyz ON foo.t (x)"
)
def test_drop_index_schema(self):
3
Source : test_constraints.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_index_against_text_separate(self):
metadata = MetaData()
idx = Index("y", text("some_function(q)"))
t = Table("x", metadata, Column("q", String(50)))
t.append_constraint(idx)
self.assert_compile(
schema.CreateIndex(idx), "CREATE INDEX y ON x (some_function(q))"
)
def test_index_against_text_inline(self):
3
Source : test_constraints.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_index_against_text_inline(self):
metadata = MetaData()
idx = Index("y", text("some_function(q)"))
Table("x", metadata, Column("q", String(50)), idx)
self.assert_compile(
schema.CreateIndex(idx), "CREATE INDEX y ON x (some_function(q))"
)
def test_index_declaration_inline(self):
3
Source : test_constraints.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_index_declaration_inline(self):
metadata = MetaData()
t1 = Table(
"t1",
metadata,
Column("x", Integer),
Column("y", Integer),
Index("foo", "x", "y"),
)
self.assert_compile(
schema.CreateIndex(list(t1.indexes)[0]),
"CREATE INDEX foo ON t1 (x, y)",
)
def _test_deferrable(self, constraint_factory):
3
Source : test_constraints.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_render_index_sql_literal(self):
t, t2 = self._constraint_create_fixture()
constraint = Index("name", t.c.a + 5)
self.assert_compile(
schema.CreateIndex(constraint), "CREATE INDEX name ON tbl (a + 5)"
)
3
Source : test_metadata.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_raise_expr_no_column(self):
idx = Index("foo", func.lower(5))
assert_raises_message(
exc.CompileError,
"Index 'foo' is not associated with any table.",
schema.CreateIndex(idx).compile,
dialect=testing.db.dialect,
)
assert_raises_message(
exc.CompileError,
"Index 'foo' is not associated with any table.",
schema.CreateIndex(idx).compile,
)
def test_no_warning_w_no_columns(self):
3
Source : test_metadata.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_no_warning_w_no_columns(self):
idx = Index(name="foo")
assert_raises_message(
exc.CompileError,
"Index 'foo' is not associated with any table.",
schema.CreateIndex(idx).compile,
dialect=testing.db.dialect,
)
assert_raises_message(
exc.CompileError,
"Index 'foo' is not associated with any table.",
schema.CreateIndex(idx).compile,
)
def test_raise_clauseelement_not_a_column(self):
3
Source : test_metadata.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_colliding_col_label_from_index_flag(self):
t1 = self._colliding_name_fixture(
{"ix": "ix_%(column_0_label)s"}, {"index": True}
)
idx = list(t1.indexes)[0]
# name is generated up front. alembic really prefers this
eq_(idx.name, "ix_foo_id")
self.assert_compile(
CreateIndex(idx), "CREATE INDEX ix_foo_id ON foo (id)"
)
def test_colliding_col_label_from_unique_flag(self):
3
Source : test_metadata.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_colliding_col_label_from_index_obj(self):
t1 = self._colliding_name_fixture({"ix": "ix_%(column_0_label)s"}, {})
idx = Index(None, t1.c.id)
is_(idx, list(t1.indexes)[0])
eq_(idx.name, "ix_foo_id")
self.assert_compile(
CreateIndex(idx), "CREATE INDEX ix_foo_id ON foo (id)"
)
def test_colliding_col_label_from_unique_obj(self):
3
Source : test_metadata.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_ix_allcols_truncation(self):
u1 = self._fixture(
naming_convention={"ix": "ix_%(table_name)s_%(column_0N_name)s"}
)
ix = Index(None, u1.c.data, u1.c.data2, u1.c.data3)
dialect = default.DefaultDialect()
dialect.max_identifier_length = 15
self.assert_compile(
schema.CreateIndex(ix),
"CREATE INDEX ix_user_2de9 ON " '"user" (data, "Data2", "Data3")',
dialect=dialect,
)
def test_ix_name(self):
3
Source : test_metadata.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_expression_index(self):
m = MetaData(naming_convention={"ix": "ix_%(column_0_label)s"})
t = Table("t", m, Column("q", Integer), Column("p", Integer))
ix = Index(None, t.c.q + 5)
t.append_constraint(ix)
# huh. pretty cool
self.assert_compile(
CreateIndex(ix), "CREATE INDEX ix_t_q ON t (q + 5)"
)
3
Source : test_quote.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_quote_flag_propagate_index(self):
m = MetaData()
t = Table("t", m, Column("x", Integer, quote=True))
idx = Index("foo", t.c.x)
self.assert_compile(
schema.CreateIndex(idx), 'CREATE INDEX foo ON t ("x")'
)
def test_quote_flag_propagate_anon_label(self):
3
Source : commands.py
with BSD 2-Clause "Simplified" License
from limodou
with BSD 2-Clause "Simplified" License
from limodou
def handle(self, options, global_options, *args):
from sqlalchemy.schema import CreateTable, CreateIndex
engine = get_engine(options, global_options)
tables = get_sorted_tables(get_tables(global_options.apps_dir, args,
engine_name=options.engine, settings_file=global_options.settings,
local_settings_file=global_options.local_settings))
for name, t in tables:
if t.__mapping_only__:
continue
print("{};".format(safe_str(u(CreateTable(t).compile(dialect=engine.dialect)))))
for x in t.indexes:
print("{};".format(CreateIndex(x)))
class SQLTableCommand(SQLCommandMixin, Command):
3
Source : __init__.py
with BSD 2-Clause "Simplified" License
from limodou
with BSD 2-Clause "Simplified" License
from limodou
def print_model(model, engine_name=None, skipblank=False):
from sqlalchemy.schema import CreateTable, CreateIndex
engine = engine_manager[engine_name].engine
M = get_model(model)
t = M.table
s = []
s.append("%s;" % str(CreateTable(t).compile(dialect=engine.dialect)).rstrip())
for x in t.indexes:
s.append("%s;" % CreateIndex(x))
sql = '\n'.join(s)
if skipblank:
return re.sub('[\t\n]+', '', sql)
else:
return sql
def do_(query, ec=None, args=None, found_rows=False, **kwargs):
3
Source : mssql.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def create_index(self, index: "Index") -> None:
# this likely defaults to None if not present, so get()
# should normally not return the default value. being
# defensive in any case
mssql_include = index.kwargs.get("mssql_include", None) or ()
assert index.table is not None
for col in mssql_include:
if col not in index.table.c:
index.table.append_column(Column(col, sqltypes.NullType))
self._exec(CreateIndex(index))
def bulk_insert( # type:ignore[override]
3
Source : postgresql.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def create_index(self, index):
# this likely defaults to None if not present, so get()
# should normally not return the default value. being
# defensive in any case
postgresql_include = index.kwargs.get("postgresql_include", None) or ()
for col in postgresql_include:
if col not in index.table.c:
index.table.append_column(Column(col, sqltypes.NullType))
self._exec(CreateIndex(index))
def prep_table_for_batch(self, batch_impl, table):
3
Source : schemacompare.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def __eq__(self, other):
return (
str(schema.CreateIndex(self.index))
== str(schema.CreateIndex(other))
and self.index.dialect_kwargs == other.dialect_kwargs
)
def __ne__(self, other):
3
Source : test_compiler.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def test_index_where(self):
metadata = MetaData()
tbl = Table("test", metadata, Column("data", Integer))
idx = Index("test_idx_data_1", tbl.c.data, mssql_where=tbl.c.data > 1)
self.assert_compile(
schema.CreateIndex(idx),
"CREATE INDEX test_idx_data_1 ON test (data) WHERE data > 1",
)
idx = Index("test_idx_data_1", tbl.c.data, mssql_where="data > 1")
self.assert_compile(
schema.CreateIndex(idx),
"CREATE INDEX test_idx_data_1 ON test (data) WHERE data > 1",
)
def test_index_ordering(self):
3
Source : test_compiler.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def test_index_extra_include_2(self):
metadata = MetaData()
tbl = Table(
"test",
metadata,
Column("x", Integer),
Column("y", Integer),
Column("z", Integer),
)
idx = Index("foo", tbl.c.x, mssql_include=[tbl.c.y])
self.assert_compile(
schema.CreateIndex(idx), "CREATE INDEX foo ON test (x) INCLUDE (y)"
)
def test_index_include_where(self):
3
Source : test_compiler.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def test_create_index_with_prefix(self):
m = MetaData()
tbl = Table("testtbl", m, Column("data", String(255)))
idx = Index(
"test_idx1", tbl.c.data, mysql_length=10, mysql_prefix="FULLTEXT"
)
self.assert_compile(
schema.CreateIndex(idx),
"CREATE FULLTEXT INDEX test_idx1 " "ON testtbl (data(10))",
)
def test_create_index_with_text(self):
3
Source : test_compiler.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def test_create_index_with_text(self):
m = MetaData()
tbl = Table("testtbl", m, Column("data", String(255)))
idx = Index("test_idx1", text("created_at desc"), _table=tbl)
self.assert_compile(
schema.CreateIndex(idx),
"CREATE INDEX test_idx1 ON testtbl (created_at desc)",
)
def test_create_index_with_arbitrary_column_element(self):
3
Source : test_compiler.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def test_create_index_expr(self):
m = MetaData()
t1 = Table("foo", m, Column("x", Integer))
self.assert_compile(
schema.CreateIndex(Index("bar", t1.c.x > 5)),
"CREATE INDEX bar ON foo ((x > 5))",
)
def test_create_index_expr_two(self):
3
Source : test_compiler.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def test_create_index_expr_func(self):
m = MetaData()
tbl = Table("testtbl", m, Column("data", Integer))
idx1 = Index("test_idx1", func.radians(tbl.c.data))
self.assert_compile(
schema.CreateIndex(idx1),
"CREATE INDEX test_idx1 ON testtbl ((radians(data)))",
)
def test_create_index_expr_func_unary(self):
3
Source : test_compiler.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def test_create_index_expr_func_unary(self):
m = MetaData()
tbl = Table("testtbl", m, Column("data", Integer))
idx1 = Index("test_idx1", -tbl.c.data)
self.assert_compile(
schema.CreateIndex(idx1),
"CREATE INDEX test_idx1 ON testtbl ((-data))",
)
def test_deferrable_initially_kw_not_ignored(self):
3
Source : test_compiler.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def test_create_index_expr_gets_parens(self):
m = MetaData()
tbl = Table("testtbl", m, Column("x", Integer), Column("y", Integer))
idx1 = Index("test_idx1", 5 // (tbl.c.x + tbl.c.y))
self.assert_compile(
schema.CreateIndex(idx1),
"CREATE INDEX test_idx1 ON testtbl ((5 / (x + y)))",
)
def test_create_index_literals(self):
3
Source : test_compiler.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def test_index_extra_include_1(self):
metadata = MetaData()
tbl = Table(
"test",
metadata,
Column("x", Integer),
Column("y", Integer),
Column("z", Integer),
)
idx = Index("foo", tbl.c.x, postgresql_include=["y"])
self.assert_compile(
schema.CreateIndex(idx), "CREATE INDEX foo ON test (x) INCLUDE (y)"
)
def test_index_extra_include_2(self):
3
Source : test_compiler.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def test_index_extra_include_2(self):
metadata = MetaData()
tbl = Table(
"test",
metadata,
Column("x", Integer),
Column("y", Integer),
Column("z", Integer),
)
idx = Index("foo", tbl.c.x, postgresql_include=[tbl.c.y])
self.assert_compile(
schema.CreateIndex(idx), "CREATE INDEX foo ON test (x) INCLUDE (y)"
)
@testing.fixture
3
Source : test_compiler.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def test_create_index_exists(self):
m = MetaData()
t1 = Table("t1", m, Column("q", Integer))
idx = Index("my_idx", t1.c.q)
self.assert_compile(
schema.CreateIndex(idx, if_not_exists=True),
"CREATE INDEX IF NOT EXISTS my_idx ON t1 (q)",
)
def test_drop_index_exists(self):
See More Examples