Hello,

During the design of a project, I came across a situation where I will have 
2 databases.
Not a big deal, it is very well documented in Django 
docs<https://docs.djangoproject.com/en/1.5/topics/db/multi-db/>
.

Dealing with 
transactions<https://docs.djangoproject.com/en/1.5/topics/db/transactions/>even 
when having multiple databases is also trivial, simply select which 
one the transaction is about.

At a given point, I'll have to interact with both databases in the same 
view.
Consider the snippet below as an example (not tested, nor this is what I 
intend to do):

@transaction.commit_manually()  # using='db1' or using='db2' or none??
def my_view(request):
    try:
        obj1 = MyObject1()
        obj1.data = request.POST.get('data')
        obj1.save(using='db1')
        obj2 = MyObject2()
        obj2.obj1_id = obj1id
        obj2.save(using='db2')
    except:
        transaction.rollback()
    else:
        transaction.commit()
    ...


I didn't find any mention in the docs or in this list related to this, so 
here is my question:

How can I do a transaction management in both databases at the same time? 
Is that even possible?


Thanks in advance for your help.
Leandro.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to