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 m.bu...@ieee.org
Django does not currently have a database schema management tool (with
the exception of syncdb and sql* commands).
Erik
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:
It's not possible to reset the automatically generated IDs in a
platform-independent way because of the huge differences between (say)
PostgreSQL serials vs. Oracle sequences (which as far as I can tell
actually require a stored procedure to increment the sequence and insert
the value into a table, though I am no Oracle expert).
If you can suggest a suitable API then it might be considered for
inclusion into Django in some future version. The API reference is still
available, by the way, at
http://docs.djangoproject.com/en/dev/topics/db/queries/
In the meantime you are left with raw SQL as the only suitable way to do
what you want, and the API documentation does give you some guidance as
to how to implement raw SQL. As for the exact details of the counter
reset, you'd need to tell us which database engine you are running against.
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/