Access the Python shell

Access the Python shell with,

$ python manage.py shell

This will take you to a Python shell which should look like this,
Selection_032
However,

$ python manage.py dbshell

will take you to a ‘sqlite’ shell if it is installed, which looks like this,
Selection_033
This can also be accessed outside of Django with,

$ sqlite3

Selection_034
So continuing now in the Python shell (not dbshell) connect with the models in your app using,

>>> from <appname>.models import <model1>, <model2>

Have a look at everything in the models1

models.objects.all()

Accessing an sqlite3 database

To access sqlite3 from the command line.

$ sqlite3

Now you are in the sqlite3 shell. Next connect to an sqlite3 database called db.sqlite3

sqlite> .open db.sqlite3

List tables in database

sqlite> .tables

Let us see what is in the table called table_name

sqlite> select * from table_name;

Not forgetting the trailing semicolon.
Ctrl+D will allow you exit this shell.
To view a table’s field names,

sqlite> PRAGMA table_info(table_name);

To view a table’s schema,

sqlite> .schema table_name