SQLAlchemy postgresql.ARRAY大小

ura*_*ash 1 postgresql sqlalchemy

如何在SQLAlchemy中添加postgres数组的大小?

像SQL类型Integer [2]:

column = Column(postgresql.ARRAY(Integer), size=2)
Run Code Online (Sandbox Code Playgroud)

Erw*_*ter 5

在PostgreSQL中,您只需将列定义为某种基类型的ARRAY,例如integer[].您可以在类型声明中包含维度integer[3][3],但它们没有效果,因为它们没有强制执行.我在这里引用手册:

但是,当前实现忽略任何提供的数组大小限制,即行为与未指定长度的数组相同.