How do I automatically clear a specific table in my SQLdatabase in my python script, including resetting ID numbers?
I know that you can clear a table (including resetting id numbers) from the SQLconsole via something like https://stackoverflow.com/questions/23038422/reset-id-count-after-table-delete or https://www.pythonanywhere.com/forums/topic/9312/ ;
However, these are all from the SQL console and not the python script. I wish to do it from the python script because then this process can be automatic: I can click a href link on my website and then it will clear all the data from the website, causing reloading to remove all the things created from the database. (I'm finished with this great tutorial: https://blog.pythonanywhere.com/121/ , but I want to know how to delete the comments)
Another method is my current one:
db = SQLAlchemy(app) ... class Comment(db.Model): ... db.session.query(Comment).delete() db.session.commit()
Unfortunately, the unique id counter is not reset, hence my question.
Any help would be appreciated! Thank you.