Michael,

Thanks for reply but I know about that. The question is how do I
access a record that requires default value from withing that
function. Something like the following:

def prev_balance():
  new_bal = get_record_that_is_being_inserted() # <=== that is what
I'm looking for
  return
build_subquery_to_retrieve_previous_balance_value(new_bal.account,
new_bal.date) # <=== I know how to do that part

balances = Table('balances', meta,
  Column('account', Integer, ForeignKey('accounts.id'),
nullable=False, primary_key=True),
  Column('date', Date, nullable=False, primary_key=True),
  Column('value', Numeric(12,2), nullable=False,default=prev_balance),
)

On Mar 1, 4:30 pm, "Michael Bayer" <[EMAIL PROTECTED]> wrote:
> use a python function as your column default ?
>
> http://www.sqlalchemy.org/docs/metadata.myt#metadata_defaults_oninsert
>
> On Feb 28, 6:00 pm, "askel" <[EMAIL PROTECTED]> wrote:
>
> > Hello everyone,
>
> > Is there a way to access current record from DefaultGenerator? I have
> > balances table that collect information on daily basis. Whenever a new
> > record inserted in that table it has to "inherit" some information
> > from previous day record. Of course, I can implement that using SQL-
> > server capabilities but I'd rather not go that way.
>
> > So basically, I need an access to a record to be inserted when
> > generator is asked for a value.
>
> > Thanks


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to