I am using Django with Postgresql. With sqlite, when I delete all the objects, and insert new ones, pk is reset to 1. However, with Postgresql, pk keeps adding up. I came across to this post (1). The accepted answer calls for:
python manage.py sqlsequencereset myapp1 myapp2 myapp3| psql
My app is products
. But I don't know what to write on the right side of the pipe.
Here is what I tried:
# products is my app name
python manage.py sqlsequencereset products
The following message appeared:
BEGIN;
SELECT setval(pg_get_serial_sequence('"products_category"','id'), coalesce(max("id"), 1), max("id") IS NOT null) FROM "products_category";
SELECT setval(pg_get_serial_sequence('"products_product_categories"','id'), coalesce(max("id"), 1), max("id") IS NOT null) FROM "products_product_categories";
SELECT setval(pg_get_serial_sequence('"products_product"','id'), coalesce(max("id"), 1), max("id") IS NOT null) FROM "products_product";
COMMIT;
I then tried:
python manage.py sqlsequencereset products | psql
Here is the error message:
-bash: psql: command not found
Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>
BrokenPipeError: [Errno 32] Broken pipe
What should I put after the |
?