List Info

Thread: Custom SQL to delete cache table




Custom SQL to delete cache table
user name
2007-11-05 21:21:53
Hi all,

I'm trying to clear the cache table.  Here's the code I'm using with Python 2.5 and Django version 0.96:

def clear_cache():
 ;   from django.db import connection
    cursor = connection.cursor()
  ;  cursor.execute("DELETE FROM django_cache WHERE 1=1")

This is for the a SQLite3 backend, but it doesn't seem to work.  I tried executing it in the command line and the table still doesn't clear.  Is there something obvious I'm missing?

- Hugh

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

Re: Custom SQL to delete cache table
country flaguser name
Australia
2007-11-06 20:26:54
On Mon, 2007-11-05 at 19:21 -0800, Hugh Bien wrote:
> Hi all,
> 
> 
> I'm trying to clear the cache table.  Here's the code
I'm using with
> Python 2.5 and Django version 0.96:
> 
> 
> def clear_cache():
>     from django.db import connection
>     cursor = connection.cursor()
>     cursor.execute("DELETE FROM django_cache WHERE
1=1")
> 
> 
> This is for the a SQLite3 backend, but it doesn't seem
to work.  I
> tried executing it in the command line and the table
still doesn't
> clear.  Is there something obvious I'm missing?

django.db.transaction.commit_unless_managed() is probably
going to be
necessary, since you're implicitly in a transaction here.

Regards,
Malcolm

> 
-- 
What if there were no hypothetical questions? 
http://www.pointy-s
tick.com/blog/


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


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )