Hi there,

There are some queries that cannot be handled at the object level. For
those I have to use the Select() function et al by doing:

from sqlobject.sqlbuilder import *

Problem is, I need to define a transaction around a set of queries,
inserts and updates, so I wrote the following:

query = Select([func.Max(Company.q.id)])
# Now I need a connection object, is this a proper way to get one?
conn = hub.begin()
result = conn.queryOne(conn.sqlrepr(query))
maxid = result[0]

new_company = Company(id=maxid, name='Acme, Inc', website='acme.com')
... # other subsequent updates, etc.
...
conn.commit() # or should this be hub.commit()
hub.end()

In general, is this the correct way to manually establish a trasaction
boundary? Do you guys see anything that I did wrong?  Of course in the
real code it'll be protected by try: except:, but to rollback, which
one do I use the conn.rollback() or hub.rollback()

Hopefully this can be helpful for others because this kind of usage is
not unique at all.

Thanks for any help!
Will


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to