at 11:23:17 PM UTC+8, Michael Bayer wrote:
On 5/11/15 11:16 AM, Geo wrote:
Ok, I got this working by adding the following code into the base class:
parent_lazy = relation(
'Node',
remote_side=[id],
backref=backref(
'children_lazy',
collection_class
Well, my case is a bit different. I'm writing a nightly running batch
script. And this script is not running inside pyramid context, which means
it is not the model that called from the framework. Instead, I arrange it
to run by system cron. But, I'm trying to utilize the pyramid environment
Ok I found the solution, just move the first query into the transaction
body:
import transaction
try:
transaction.begin()
x_members = session.query(Distributor)...
for member in x_members:
.
except:
transaction.abort()
BTW, I'm using pyramid framework, which is using the
I have a query to join another two querys which are written as
subqueries:
paid_120_count = session.query(Capital_invest.member_id,
func.count().label(count)).\
join(Product,
Capital_invest.prod_id==Product.prodid).\
I have a tested update ... from.. statement, like so:
update distributors set lead_bonus = lead_bonus + a.sum_amt
from (
select target_member as id, sum(amount) as sum_amt
from bonus_gen_history
where bonus_type=2 and sub_type=1 and source_member in
(select
I have a self-reference table,
class member:
id
upline_id = Column(Integer, ForeignKey('member.id'))
status
downlines = relationship('member',
backref=backref('upline', remote_side=id))
def setUpline(self, upline_id)
session =
I have tables which linked as a one to many relationship:
user ---(one to many)--- order --(many to one)--product
Product has been populated and served as a lookup table.
class User:
member_id
purchase_total
order = relationship(Order)
def add_product(self,