Wanderful!
This was exactly what I needed!

There is any documentation about "call_command" and the other commnds 
you used?


Thanks alot.
    Mirto

felix ha scritto:
>
> here's what I'm using:
>
>     from django.core import management
>     from django.db import connection
>     cursor = connection.cursor()
>     # don't delete these tables
>     # note that I'm also keeping auth_user
>     tables = 
> ['comments','objekt_objekt','tag','tags','user_objekt_tag','auth_user','auth_session']
>
>     current_tables = connection.introspection.table_names()
>    
>     for table in current_tables:
>         if table not in tables:
>             try:
>                 cursor.execute("drop table %s" % table)
>             except Exception,e:
>                 raise e
>                 #pass
>
>     management.call_command('syncdb')
>
>
>
>
>
>
>
> On Fri, Oct 17, 2008 at 3:41 PM, Mirto Silvio Busico 
> <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:
>
>
>     Sorry  I was not clear.
>
>     I have some utilities in view.py which have to reload tables content
>     (migration from the legacy database; clearing a table and
>     reloading with
>     base content; ...)
>
>     I know from the shell it is enough an "python manage py flush", but I
>     have two problems:
>
>        * the action have to be triggered by a user action on a form
>        * the id have to be resetted because for me the id=0 and id=1 rows
>          have a fixed special meaning
>
>     I have not found anything about deleting tables in
>     http://docs.djangoproject.com/en/dev/topics/db/queries/ (it seems that
>     "database api" has gone in 1.0)
>     The only thing that seems I can use is "Executing custom SQL" in
>     http://docs.djangoproject.com/en/dev/topics/db/models/
>
>     There is a better/recommended method?
>
>     Thanks
>        Mirto
>
>
>     Erik Allik ha scritto:
>     > $ manage.py dbshell
>     >  > DROP TABLE table_name;
>     >
>     > Django does not currently have a database schema management tool
>     (with
>     > the exception of syncdb and sql* commands).
>     >
>     > Erik
>     >
>     >
>     > On 17.10.2008, at 15:30, Mirto Silvio Busico wrote:
>     >
>     >
>     >> Hi all,
>     >>
>     >> what is the django way o deleting all table content and
>     resetting the
>     >> primary key counter?
>     >>
>     >> Thanks
>     >>    Mirto
>     >>
>     >> --
>     >>
>     >>
>     _________________________________________________________________________
>     >> Busico Mirto Silvio
>     >> Consulente ICT
>     >> cell. 333 4562651
>     >> email [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
>     >>
>     >>
>     >>
>     >
>     >
>     > >
>     >
>     >
>
>
>     --
>
>     _________________________________________________________________________
>     Busico Mirto Silvio
>     Consulente ICT
>     cell. 333 4562651
>     email [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
>
>
>
>
>
> >


-- 

_________________________________________________________________________
Busico Mirto Silvio
Consulente ICT
cell. 333 4562651
email [EMAIL PROTECTED]


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to