Using SQLAlchemy, you can add a default value for each function. As I understand it, this can also be called (either without arguments, or with an optional argument ExecutionContext).
Now, in a declarative scenario, I am wondering if it is possible in any way to have a default function that is called with the object that is being stored. That is, it is possible like this:
Base = sqlalchemy.ext.declarative.declarative_base()
class BaseEntity(Base):
value = Column('value', String(40), default=BaseEntity.gen_default)
def gen_default(self):
return self.default_value
Is something like this possible? Or do I need to somehow adjust the hook before inserting for this (how?)?
source
share