【发布时间】:2014-01-03 21:57:14
【问题描述】:
我正在尝试在 file_name 列上创建一个非唯一索引。我期待一个高基数,比如 1,000 行,有 950 个唯一文件名。
file_collection = Table ('file_collection', metadata,
Column('id', Integer, primary_key=True),
Column('full_path', String, unique=True, nullable=False),
Column('file_name', String, index=True, nullable=False)
)
我的方言是 sqlite。当我创建表时,file_name 列上没有创建非唯一键
CREATE TABLE file_collection (
id INTEGER NOT NULL,
full_path VARCHAR NOT NULL,
file_name VARCHAR NOT NULL,
PRIMARY KEY (id),
UNIQUE (full_path)
)
如何在file_name 列上创建非唯一键?
【问题讨论】:
-
您如何获得问题中显示的
CREATE TABLE代码? -
这个函数的第二个参数
engine = create_engine('sqlite:///test.db', echo=True)
标签: sqlite sqlalchemy