I have:
model.py
class ItemObjects(Base):
__tablename__ = "OBJT"
ID = Column(Integer, primary_key=True, index=True)
O_MAILITEM = Column(String, index=True)
shema.py
class ItemObjects(ObjectsBase):
ID:int
O_MAILITEM:str
crud.py
def get_objects(db: Session, skip: int = 0, limit: int = 100):
return db.query(models.ItemObjects).offset(skip).limit(limit).all()
I am using SQL Server in database.py. Connection with database is ok.
So in main.py:
@app.get("/objects/", response_model = schemas.ObjectsBase)
async def read_objects(skip: int = 0, limit: int = 100, db: Session = Depends(get_db)):
lobjects = crud.get_objects(db, skip=skip, limit=limit)
return lobjects
when i run i have received this error:

.
In database;
I have a table "OBJT" in database with same colunns [e.g. ID, O_MAILITEM, O_A_NAME, and others colunns].
Can you help me to solve this?
I think the issue is that you need ObjectsBase to have orm_mode = True in its Config -- search for orm_mode here for more detail. Try that and report back?
I _think_ the issue is that you need
ObjectsBaseto haveorm_mode = Truein itsConfig-- search fororm_modehere for more detail. Try that and report back?
Hi,
Thanks for your feedback, but return same error.
I put in Shema.py: class Config: orm_mode = True
met the same question , any solution here?
met the same question , any solution here?
find the answer:
previous:
@router.get('/info/get', response_model=schemas.QQMessage)
def read_qq_messages(skip: int = 0, limit: int = 100, db: Session = Depends(get_db)):
message = crud.get_qq_messages(db, skip, limit)
return message
after:
from typing import List
...
@router.get('/info/get', response_model=List[schemas.QQMessage])
def read_qq_messages(skip: int = 0, limit: int = 100, db: Session = Depends(get_db)):
message = crud.get_qq_messages(db, skip, limit)
return message
GET request's response_model is different from POST method
Thanks for the help @dmontagu!
Thanks for the report @binbinah!
@Biscai were you able to solve your problem? May we close this issue?
thanks for your help @binbinah !
@tiangolo the problem is solved. Thanks
Most helpful comment
I think the issue is that you need
ObjectsBaseto haveorm_mode = Truein itsConfig-- search fororm_modehere for more detail. Try that and report back?