def add(money): tr = Transaction(money=money) print 'tr.created_at0', tr.created_at # sa_session.add(tr) # print 'tr.created_at1', tr.created_at sa_session.commit() print 'tr.created_at2', tr.id, tr.created_at
def add(money): # sql = select([select([func.coalesce(func.sum(Transaction.money), 0) + money]).alias('tmp')]) # sql = select([func.sum(Transaction.money).label('g')]) Tr = aliased(Transaction, name="tr") sql = select([func.coalesce(func.sum(Tr.balance), 0) + money]) # sql = sa_session.query(func.sum(Transaction.money)) # .as_scalar() # .label('aa') # print dir(sql) # print 'sql', sql tr = Transaction(money=money) tr.balance = sql print "tr.created_at0", tr.created_at # tr.moeny = 4294967295 # tr.balance = -1 sa_session.add(tr) print "tr.created_at1", tr.created_at sa_session.commit() print "tr.created_at2", tr.created_at