The title pretty much sums up my question, but here are more details:
I'm running a script to import rows into a heroku database. I started getting errors:
<class 'django.db.utils.DatabaseError'> current transaction is aborted, commands ignored until end of transaction block`
The script runs smoothly on my localhost so I'm not looking for problems there. I recently received an email from heroku stating that I'm "Approaching row limit for dev database"
I'm assuming I hit the row limit but I'd like to confirm this before taking further action.
Does anyone know how I can find my current row count for the whole database? (I know I can just do a count on each table but I'm hoping there's a cleaner way)
"You could run heroku pg:psql to fire up a Postgres console, then issue \d to see all tables, and \d tablename to see details for a particular table." You can also type select * from tablename; to view the table contents.
You can find them by visiting the Resources tab on your Dashboard then clicking on the DB you use. It will take you to the Addons page in another tab. Click on the Settings tab then View Credentials. Using these credentials, you can use Adminer to login to the DB.
The Heroku Postgres dev plan will be limited to 10,000 rows.
From the application dashboard on Heroku, go to the 'resources' tab and search for postgres. Provision it and use the free option. There's now a clickable link to the Datastore associated with your application. Go ahead and open the link to your datastore, and take note of exactly how to get here again.
If you have the heroku cli tool, this will give you, among other things, the number of rows in your database
heroku pg:info -a your_app
Also given are your plan type, the db status, the number of current connections, postgres version, when the db was created, the number of rows in your plan, the data size, the number of tables and if your db has any fork/follow options activated.
This will give you the approximate count of all rows within your database:
SELECT sum(reltuples) from pg_class where relname IN (SELECT c.relname FROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace WHERE c.relkind = 'r' AND n.nspname <> 'pg_catalog' AND n.nspname <> 'information_schema' AND n.nspname !~ '^pg_toast' AND pg_catalog.pg_table_is_visible(c.oid));
Though the error message indicates some error on your database, likely a constraint violation versus something with your insert privileges being revoked.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With