When making an sqlAlchemy model for an array, give below
class Post(base):
__tablename__ = "posts"
answer = column(Array[string],nullable=false)
sqlAlchemy throws fllowing error,
TypeError: Array() missing 1 required positional argument: 'sequence'
what am I doing wrong?
CodePudding user response:
It seems you are not defining the table definition correctly. See the sample table definition.
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import String, Column
from sqlalchemy.dialects.postgresql import ARRAY
Base = declarative_base()
class Post(Base):
__tablename__ = 'post'
id = Column(Integer, primary_key=True)
answer = Column(ARRAY(String))
References: