So you would have to insert records for each object individually, then call
distributed_transaction_commit.


dba.customers.insert(....)
dbb.sales.insert(....)

dba.distributed_transaction_commit(dba, dbb)



How would you perform a join?

dba(dba.customers.id == dbb.sales.id_customer).select()

for row in rows:
   row.customers.name, row.sales.total
   row.update_record(sales.tax=1.08)

dba.distributed_transaction_commit(dba,dbb)

-Thadeus




On Thu, Oct 29, 2009 at 4:46 PM, mdipierro <mdipie...@cs.depaul.edu> wrote:

>
> There is a single function. In your case you would call
>
>    dba.distributed_transaction_commit(dba,dbb)
>
> or
>
> try:
>    dba.distributed_transaction_commit(dba,dbb)
> except:
>    session.flash="distributed transaction failed and rolled back"
>
> I have not tried this in some time but when I tried worked fine.
> postgresql only.
>
>
> On Oct 29, 4:39 pm, Thadeus Burgess <thade...@thadeusb.com> wrote:
> > Massimo,
> >
> > Would you mind giving a more in depth example on distributed transactions
> > with postgres? I know web2py supports them, however there is not much
> > information on it. How would you accomplish a join across databases?
> >
> > Is there an api to abstract this?
> >
> > dba = DAL('postgres...')
> > dbb = DAL('postgrse...')
> >
> > dba.define_table('customers'....)
> > dba.define_table('employees'....)
> > dbb.define_table('products'....)
> > dbb.define_table('sales'.....)
> >
> > db = DISTRIBUTED_DAL(dba, dbb)
> >
> > rows = db(db.customers.id == request.vars.cust_id)(db.sales.id ==
> > request.vars.sale_id).select()
> >
> > for row in rows:
> >    print row.customer.name, row.customer.address, row.sale.time,
> > row.sale.product.name
> >
> > -Thadeus
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to