Thanks Tim, in that case I will carry on this way.

2009/8/23 Tim Chase <django.us...@tim.thechases.com>:
>
>> The raw SQL is something along the lines of "INSERT INTO backup SELECT
>> * FROM today; DELETE FROM today;".
>>
>> Is there a Django way of doing this? I would required something
>> similiar to this:
>> todays_records = Today.objects.all()
>> for record in todays_records:
>>     Backup.objects.create(record)
>
> While you could do something like this Python/Django code, your
> raw SQL is far more efficient -- your transaction logs should
> have the two commands.  Depending on the quantity of data, the
> Python/Django way of doing this may have lots of INSERTs in your
> transaction logs.
>
> Another possibility might be to have the .save() method save into
> both places ([today] and [backup]) so you can just DELETE FROM
> [today] and already have the content in [backup].
>
> As an aside, the DELETE FROM is more portable, but in some
> environments TRUNCATE TABLE tblFoo is a more efficient way to
> clear out the contents (but may have auto-increment resetting
> side-effects).
>
> So I'd just stick with your current solution and not try to use
> the Django ORM.
>
> -tim
>
>
>
> >
>

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

Reply via email to