I have such model:
class Test(db.Model):
__tablename__ = 'test'
id = db.Column(db.Integer, primary_key=True)
subject = db.Column(db.String(512), nullable=False)
level = None
Some code generate RAW SQL with additional dynamic data.
For example it like:
db.session.query(Test).from_statement("SELECT test.id AS test_id,
test.subject AS test_subject, 99 AS level FROM test").all()
It generate list of python objects , but how I can fill attribute
"additional" for these python objects?
I don't want store NULL column "additional" in database.
I want create dynamic additional data with SQL and add it to python
objects.
I tried add temporary column to table (but I not want store it in db)
like this:
from sqlalchemy.schema import Column
from sqlalchemy.types import Integer
level_column = Column('level', Integer)
Test.__table__.append_column(level_column)
but if I do:
db.session.query(Test).from_statement("SELECT test.id AS test_id,
test.subject AS test_subject, 99 AS level FROM test").all()
this objects don't have filled with level 99, it has level = None.
Help please.
Thanks
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.