Item create (text) API #6

Open
opened 2025-05-01 01:53:46 +02:00 by osbm · 1 comment
Owner
No description provided.
osbm added this to the Todo project 2025-05-01 01:53:46 +02:00
Owner

`class Items(Base):
tablename = "items_table"

item_id = Column(Integer, primary_key=True, index=True)
user_id = Column(Integer, ForeignKey("users_table.user_id"), nullable=False)
#collection_id = Column(Integer, ForeignKey("collections_table.collection_id"), nullable=False)
item_created_date = Column(String, default=datetime.now())
item_location = Column(String, default="No location") #daha net tanımlancak
item_type = Column(String, default="No type")
item_content = Column(String, default="No content")
item_score = Column(Float, default=0.0)`

collection_id eklendiği zaman şöyle bir hata meydana geliyor ->

File "/home/bedir/Documents/VSCODE/manhan-fastapi/myenv/lib/python3.12/site-packages/sqlalchemy/sql/schema.py", line 3223, in _resolve_column raise exc.NoReferencedTableError( sqlalchemy.exc.NoReferencedTableError: Foreign key associated with column 'items_table.collection_id' could not find table 'collections_table' with which to generate a foreign key to target column 'collection_id' ERROR Application startup failed. Exiting.

`class Collections(Base):
tablename = "collections_table"

collection_id = Column(Integer, index=True, primary_key=True , autoincrement=True)
user_id = Column(Integer, ForeignKey('users_table.user_id'), nullable=False)
visibility = Column(Boolean, default=True)
colllection_name = Column(String, default="No name")
collection_description = Column(String, default="No description")`

bu collections tablosu
sorunu çözülmeli

`class Items(Base): __tablename__ = "items_table" item_id = Column(Integer, primary_key=True, index=True) user_id = Column(Integer, ForeignKey("users_table.user_id"), nullable=False) #collection_id = Column(Integer, ForeignKey("collections_table.collection_id"), nullable=False) item_created_date = Column(String, default=datetime.now()) item_location = Column(String, default="No location") #daha net tanımlancak item_type = Column(String, default="No type") item_content = Column(String, default="No content") item_score = Column(Float, default=0.0)` collection_id eklendiği zaman şöyle bir hata meydana geliyor -> ` File "/home/bedir/Documents/VSCODE/manhan-fastapi/myenv/lib/python3.12/site-packages/sqlalchemy/sql/schema.py", line 3223, in _resolve_column raise exc.NoReferencedTableError( sqlalchemy.exc.NoReferencedTableError: Foreign key associated with column 'items_table.collection_id' could not find table 'collections_table' with which to generate a foreign key to target column 'collection_id' ERROR Application startup failed. Exiting.` `class Collections(Base): __tablename__ = "collections_table" collection_id = Column(Integer, index=True, primary_key=True , autoincrement=True) user_id = Column(Integer, ForeignKey('users_table.user_id'), nullable=False) visibility = Column(Boolean, default=True) colllection_name = Column(String, default="No name") collection_description = Column(String, default="No description")` bu collections tablosu sorunu çözülmeli
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: manhan/backend#6
No description provided.