0

I'm using django to create a database and I manually created a test values in the database by creating objects and saving them to the database. Now when I run this query:

select TABLE_NAME, 
       TABLE_ROWS 
from information_schema.tables 
where table_schema = 'test_test_db';

It returns the tables with the correct number of rows. For example, a table 'accounts_users' has 4269 rows.

But when I try to select any values using select username from accounts_users;, I get 0 rows back or 'Empty Set' result.

And of course my django app cannot run because there is "no" data in the database.

What is wrong?

  • 1
    Are you sure you are connected to the right database? – Tom V Aug 10 '17 at 12:44
  • yup I'm sure I selected the right one – Ahmedn1 Aug 10 '17 at 13:01
  • Assuming this is not a production DB yet, I'd try inserting test values into accounts_users, and see if you can get values back out of it then. You could also confirm that, after inserting additional rows, the row count from information_schema.tables has updated. If the INSERT lets you SELECT a row back, and the row count from tables hasn't updated, maybe you are looking at different copies of your table after all. – RDFozz Aug 10 '17 at 20:57
  • Did you try dropping the django user and re granting django access? – DrDamnit Aug 11 '17 at 5:43
  • I tried manually adding a test user and the TABLE_ROWS was updated "4270" but when I select I get only the test user I added. Anyway, I learned that TABLE_ROWS is only a rough estimate and I guess it is not updated regularly enough. – Ahmedn1 Aug 12 '17 at 12:50
1

I tried manually adding a test user and the TABLE_ROWS was updated "4270" but when I select I get only the test user I added. Anyway, I learned that TABLE_ROWS is only a rough estimate and I guess it is not updated regularly enough.

  • Rarely is TABLE_ROWS off by more than a factor of two. I have never seen a non-zero value for an empty table. So, I think there is still something wrong here, but I can't think what. – Rick James Aug 17 '17 at 14:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.