Re: rollback the update query

2015-05-13 Thread Simran Singh
Hi Tom, Thanks a lot for your efforts. It worked with savepoint called before update query. Thank you Regards, Simran On Monday, May 11, 2015 at 4:27:50 PM UTC+5:30, Simran Singh wrote: > > I am really new to Django and I am using Django 1.8. Many of the > manual_transaction feat

Re: rollback the update query

2015-05-13 Thread Simran Singh
Hi James, Yes, it workedd :) I created the object outside the method and called it at every transaction point in the loop and when there is rollback, it rollbacks all the queries. Thanks James Regards, Simran On Monday, May 11, 2015 at 4:27:50 PM UTC+5:30, Simran Singh wrote: > > I am really

Re: rollback the update query

2015-05-13 Thread James Schneider
Did you try changing the position of the save point like I mentioned? -James On May 13, 2015 9:33 PM, "Simran Singh" wrote: > Hi James, > > Thanks for your feedback. I basically want to rollback that query where I > update the db. Basically I want to rollback all the updates that were made > dur

Re: rollback the update query

2015-05-13 Thread Simran Singh
Hi James, Thanks for your feedback. I basically want to rollback that query where I update the db. Basically I want to rollback all the updates that were made during that transaction. Tried out the method of custom Exception as suggested by Tom but somehow my bad luck that it is still not worki

Re: rollback the update query

2015-05-13 Thread Simran Singh
Hi Tom, I tried the code that you posted but somehow it is giving* UnexpectedNoAssetSpecificationException at /reservation/ *error. I am not sure but when this exception is raised, then control is not going to class UnexpectedNoAssetSpecificationException(Exception): pass and when it goes

Re: rollback the update query

2015-05-13 Thread James Schneider
> asset_spec = AssetSpecification.objects.filter(asset_id_id=inventory,utilized_value=0).values_list('asset_id', flat=True) > trans = transaction.savepoint() // Here I am trying not to commit the code and store it in transaction. > > if

Re: rollback the update query

2015-05-13 Thread Simran Singh
Hi Tom, All these conditions are to be verified before data received from the form is saved in database. I tried this Exception method but when the control goes to except block, new page is rendered but *all the transactions that were completed till this point are committed after this point*.

Re: rollback the update query

2015-05-13 Thread Tom Evans
On Wed, May 13, 2015 at 9:37 AM, Simran Singh wrote: > Tom, basically I want to discard everything that is stored in > transaction.savepoint. As per my current case, it is getting committed no > matter where the flow goes. Yes, so you don't want savepoints. Savepoints are for rolling back a *subs

Re: rollback the update query

2015-05-13 Thread Simran Singh
Tom, basically I want to discard everything that is stored in transaction.savepoint. As per my current case, it is getting committed no matter where the flow goes. Regards, Simran On Monday, May 11, 2015 at 4:27:50 PM UTC+5:30, Simran Singh wrote: > > I am really new to Django and I am using Dj

Re: rollback the update query

2015-05-13 Thread Tom Evans
On Wed, May 13, 2015 at 6:36 AM, Simran Singh wrote: > Hi Tom, > > If you see then in if block, I am creating my savepoint. At any point of > time, if the condition is not met and control goes to else block then I want > to rollback all the changes that are saved in transaction and redirect it to

Re: rollback the update query

2015-05-12 Thread Simran Singh
Hi Tom, If you see then in *if *block, I am creating my savepoint. At any point of time, if the condition is not met and control goes to *else* block then I want to rollback all the changes that are saved in transaction and redirect it to some other page and not commit anything to db. I am able

Re: rollback the update query

2015-05-12 Thread Tom Evans
On Tue, May 12, 2015 at 7:47 AM, Simran Singh wrote: > Thanks Tom for your response. I am attaching piece of code of what I have > done. I hope this could help. > > @transaction.atomic(None, True) > def reservation(request): > > if request.method == 'POST': > reservation_form = Reserva

Re: rollback the update query

2015-05-11 Thread Simran Singh
Thanks Tom for your response. I am attaching piece of code of what I have done. I hope this could help. @transaction.atomic(None, True) def reservation(request): if request.method == 'POST': reservation_form = ReservationForm(request.POST) if reservation_form.is_valid():

Re: rollback the update query

2015-05-11 Thread Tom Evans
On Mon, May 11, 2015 at 11:44 AM, Simran Singh wrote: > I am really new to Django and I am using Django 1.8. Many of the > manual_transaction features have been depreciated in this. I have used > @transaction.atomic(None, True) nit; these are the defaults. You might as well just say: @transact

rollback the update query

2015-05-11 Thread Simran Singh
I am really new to Django and I am using Django 1.8. Many of the manual_transaction features have been depreciated in this. I have used *@transaction.atomic(None, True)* to pack the transaction and rollback the updates if at any point the condition is not met. I tried to store the transaction

Re: Update Query

2010-05-14 Thread Bill Freeman
Cool. So I guess we have a doc bug against the queryset API reference. Sim, if you're still reading this, and updating stuff in the database is what you were trying to do, then turn you computes collection of changes into a dictionary (if it isn't one already), "d" below, and do: User.objects

Re: Update Query

2010-05-14 Thread Tom Evans
On Fri, May 14, 2010 at 3:26 PM, Bill Freeman wrote: > Actually, there would be a real advantage to doing update in the > DB rather than instantiating the model, changing it, and saving it, > since sql update is a single transaction.  If that's what queryset > update does, then the only issue with

Re: Update Query

2010-05-14 Thread Bill Freeman
Actually, there would be a real advantage to doing update in the DB rather than instantiating the model, changing it, and saving it, since sql update is a single transaction. If that's what queryset update does, then the only issue with your version is that you needed two asterisks, passing "some_

Re: Update Query

2010-05-14 Thread zinckiwi
On May 13, 6:48 pm, Bill Freeman wrote: > Or you could be right.  I'm still not clear on the OP's intent. I suspect both would work, with my solution relying on a queryset containing a single object. Yours is cleaner! Regards Scott -- You received this message because you are subscribed to the

Re: Update Query

2010-05-13 Thread Bill Freeman
Or you could be right. I'm still not clear on the OP's intent. On Thu, May 13, 2010 at 4:21 PM, zinckiwi wrote: > Quite right, I was confusing it with QuerySet's update(), as > demonstrated in the docs: > > # Update all the headlines with pub_date in 2007. > Entry.objects.filter(pub_date__year=2

Re: Update Query

2010-05-13 Thread zinckiwi
Quite right, I was confusing it with QuerySet's update(), as demonstrated in the docs: # Update all the headlines with pub_date in 2007. Entry.objects.filter(pub_date__year=2007).update(headline='Everything is the same') Regards Scott On May 13, 3:14 pm, Bill Freeman wrote: > Update still take

Re: Update Query

2010-05-13 Thread Bill Freeman
Update still takes exactly one argument: self. I'm still not completely clear on what the OP is trying to do so I'll guess that for a given User object (id == 11) you want to adjust a set of attributes not known apriori, but available as key - value pairs from an itterator I'll call 'd.items()':

Re: Update Query

2010-05-13 Thread zinckiwi
> What if field_name and value coming from loop? > I have around 50 field and values in loop. > Can I do this? I know this is silly way to do but please guide how can > I do this? > > for key, value in users: >    user."%s" = "%s" % (key, value) > > user.save() Ah, I see. In that case you will wan

Re: Update Query

2010-05-13 Thread sim
Scott, Thank you very much for your reply and giving me very nice and simpler idea but I have one question: What if field_name and value coming from loop? I have around 50 field and values in loop. Can I do this? I know this is silly way to do but please guide how can I do this? for key, value in

Re: Update Query

2010-05-13 Thread zinckiwi
> I am little confused about it. I am not sure django allow this or not. > Please correct me. > > string = last_name = 'Riaz edit',  first_name = 'Asim edit', > nationality  = 'se' > User.objects.filter(id=11).update(string) > > I am using this and its giving me this error: > > update() takes exact

Update Query

2010-05-13 Thread sim
Hello All, I am little confused about it. I am not sure django allow this or not. Please correct me. string = last_name = 'Riaz edit', first_name = 'Asim edit', nationality = 'se' User.objects.filter(id=11).update(string) I am using this and its giving me this error: update() takes exactly 1

Re: update query set with a limit

2010-02-27 Thread James Bennett
On Sat, Feb 27, 2010 at 10:07 PM, Harley Bussell wrote: > Hi, id like to know if any one has found a work around to use limits > when updating a query set. This is unlikely to be supported by Django; "UPDATE ... LIMIT" is non-standard, non-portable and MySQL is the only DB supporting it out of th

update query set with a limit

2010-02-27 Thread Harley Bussell
Hi, id like to know if any one has found a work around to use limits when updating a query set. I'm trying to lock a number of the oldest rows in a table. update job set lock='lockid' where lock ='' order by created limit 10; Ideally id like to do something like this: Job.objects.filter(lock='').