[PonyORM-list] How to purge table rows
alexeymalashkevich at gmail.com
Thu Dec 19 08:34:46 UTC 2013
If I understand correctly you want to purge rows from a table and reset the
table's autoincrement counter. There is no such functionality in Pony yet,
but you can do that manually using raw SQL.
Below is the code for SQLite:
# purge rows from the table
sql1 = 'delete from "%s"' % entity._table_
# reset the autoincrement counter
sql2 = "delete from sqlite_sequence where name='%s'" \
In SQLite table names should be in double quotes and strings should be in
single quotes, that is why the queries above use different quotes (
If you're using another database, let us know which one.
On Thu, Dec 19, 2013 at 2:45 AM, Guy Jacks <guy.jacks at gmail.com> wrote:
> I'm currently calling.
> db.drop_table(...) and then calling db.create_tables() in order to purge
> all of the data. I'm using flask so I wrapped my app in the
> with_transaction context. I'm getting the following error.
> Note, I don't want to delete all the rows because I want to reset the
> auto-increment on the ids.
> ponyorm-list mailing list
> ponyorm-list at ponyorm.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the ponyorm-list