'Postgres SQLAlchemy: Additional arguments should be named <dialectname>_<argument>, got 'ForeignKey'
I am using postgres database and sqlalchemy in my python code, I created schemas and models and I want to use ForeignKey, but I got this error message:
Additional arguments should be named <dialectname>_<argument>, got 'ForeignKey'
my code:
class table1(Base):
__tablename__ = 'table1'
first_id = Column(
Integer, unique=True, nullable=False, primary_key=True, autoincrement=True
)
class table2(Base):
__tablename__ = 'table2'
second_id = Column(
Integer,
nullable=False,
primary_key=True,
)
second = Column(Integer, nullable=False, primary_key=True, ForeignKey=('table1.first_id'))
Could anyone help me with this? Thanks.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
