I am trying to create a table in SQLAlchemy ORM, where I need to specify both the schema name (for postgres) and some constraints. To specify just the schema name, one uses a dictionary:
class NewTable(Base):
__tablename__ = "new_table"
__table_args__ = {"schema": "schema_name"}
id = Column(Integer, primary_key=True)
name = Column(String(255), unique=True)
and to define just constraints the code would be:
class NewTable(Base):
__tablename__ = "new_table"
id = Column(Integer)
name = Column(String(255))
__table_args__ = (
PrimaryKeyConstraint("id", name="id_pk"),
UniqueConstraint("name")
)
, using tuples.
Does someone knows how to set the schema name in the last code block, using the tuples syntax?