Defining model
kination opened this issue · 4 comments
kination commented
Hello,
I'm currently referring polls demo for developing aiohttp server app.
One question is, there are guide about defining model in tutorial document, and it said model can be defined as class instead of using table.
class Question(Base):
__tablename__ = 'question'
id = Column(Integer, primary_key=True)
question_text = Column(String(200), nullable=False)
pub_date = Column(Date, nullable=False)
Is there any sample to develop in this way?
Thanks.
asvetlov commented
No.
Because you cannot use the given class directly but only access it by model anyway.
In the context, declarative class-based models are useless and confusing.
But you can still use the approach.
kination commented
asvetlov commented
Please create a pull request.
We discussed the subject with @gyermolenko about a year ago, pushing the decision into the docs makes sense.