On 07/03/2016 04:54 PM, James Schneider wrote:
On Jul 3, 2016 4:18 PM, "Gary Roach" <gary719_li...@verizon.net
<mailto:gary719_li...@verizon.net>> wrote:
>
> Hi all
>
>
> I'm still working on the official django tutorial
(https//docs.djangoproject.com/en/1.9/intro/tutorial/02/
<http://docs.djangoproject.com/en/1.9/intro/tutorial/02/>) on the
section that is adding the Question table.
>
> I'm using Eclipse Neon with PyDev IDE
> Django 1.9
> Pyathon 3.5
> SqLite DBMS
> OS Debian Stretch Linux
> KDE Desktop
>
> While working with the database API I have managed to run the
auto-increment field up and can't find a way to reset it. Does anyone
know how to do this. There are a lot of suggestions out there but I
have yet to find one that works.
>
That's a bit surprising. A quick Google search points at resetting the
proper values in the sqlite_sequence table.
Other options:
You can drop the table and recreate it.
You can drop the database and recreate it.
Obviously those options can have detrimental effects on your data.
The better question is why would you?
The autoincrement fields for columns are meant to be autonomous and
guaranteed unique. Toying with those values can and will lead to data
inconsistencies. That's why there isn't a 'simple' way to reset that
counter.
If you're only doing it to keep the numbers low while you're
developing, it really isn't worth it. You'll quickly reach a point
where it is not feasible to drop all of the data and start over, and
you need to ensure your dev environment is as close to production as
it can be.
-James
Thanks for the return.
Normally I would agree that messing around with the auto-increment is a
bad idea. But I am working with the tutorial and found the mismatch on
id's to be a bit of a distraction. Was the reset necessary, No. I did
learn a lot in the process though. I finally found $echo "" > db.sqlite3
completely zeroed out the file and running the makemigrations an migrate
restored everything original condition. All of this drove home the fact
that db.sqlite3 is no more than a text file and can be thrown away and
recreated any time I like. This might be handy in the future.
Thanks again.
Gary R.
--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to django-users+unsubscr...@googlegroups.com
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com
<mailto:django-users@googlegroups.com>.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/CA%2Be%2BciXLFxY8Gm_Wo1%2BftkDmiW9LB65Rs67Z1Cau1wa%3DMyPhwA%40mail.gmail.com
<https://groups.google.com/d/msgid/django-users/CA%2Be%2BciXLFxY8Gm_Wo1%2BftkDmiW9LB65Rs67Z1Cau1wa%3DMyPhwA%40mail.gmail.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/247f4e0f-6b6d-b388-fd47-144c887c1207%40verizon.net.
For more options, visit https://groups.google.com/d/optout.