gpt4 book ai didi

mysql - 在 SQLAlchemy 中,如何指定全文索引?

转载 作者:搜寻专家 更新时间:2023-10-30 20:43:42 24 4
gpt4 key购买 nike

class AccountIndexes(Base):
__tablename__ = 'account_indexes'
id = Column(Integer, primary_key = True)
user_id = Column(Integer, nullable=False, unique=True, index=True)
full_name = Column(String(255), nullable=True)
__table_args__ = {'mysql_engine':'MyISAM'}

那是我的 table 。如何在 full_name 上创建“全文索引”? (不是普通索引)

最佳答案

如果你可以检查 sqlalchemy.schemaIndex 中的代码,那么他们写了

def __init__(self, name, *columns, **kw):
"""Construct an index object.

:param name:
The name of the index

:param \*columns:
Columns to include in the index. All columns must belong to the same
table.

:param unique:
Defaults to False: create a unique index.

:param \**kw:
Other keyword arguments may be interpreted by specific dialects.

"""
self.table = None
# will call _set_parent() if table-bound column
# objects are present
ColumnCollectionMixin.__init__(self, *columns)
self.name = name
self.unique = kw.pop('unique', False)
self.kwargs = kw

现在在 Index__init__ 中,他们只检查 unique。我认为要生成全文索引,您必须使用 sqlalchemy 的 DDL 操作功能。

关于mysql - 在 SQLAlchemy 中,如何指定全文索引?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9222284/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com