Maybe better to create a sub class for valid class declaration? #94
-
hi there :) PydanticUser = sqlalchemy_to_pydantic(User)
class PydanticUser2(sqlalchemy_to_pydantic(User)):
pass
print(PydanticUser, PydanticUser2, User) the output is: <class 'User'> <class '__main__.PydanticUser2'> <class '__main__.User'> If we directly use |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
from pydantic import BaseModel Base = declarative_base() class User(Base): class BasePydanticModel(BaseModel): PydanticUser = sqlalchemy_to_pydantic(User, config=BasePydanticModel) print(PydanticUser, PydanticUser2, User) |
Beta Was this translation helpful? Give feedback.
-
Thanks for the patience with my reply! 😅 I deprecated this library a while ago in favor of SQLModel which would solve all the same use cases in a much better way, and I'm directing all the effort in that direction. SQLModel uses Pydantic models to define both data and table (SQL) models, so it's easier to do all these things. 🚀 |
Beta Was this translation helpful? Give feedback.
Thanks for the patience with my reply! 😅
I deprecated this library a while ago in favor of SQLModel which would solve all the same use cases in a much better way, and I'm directing all the effort in that direction.
SQLModel uses Pydantic models to define both data and table (SQL) models, so it's easier to do all these things. 🚀