Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

364
Views
How to view database and schema of django sqlite3 db

I am new to django framework.

I tried to create a simple blog by following djangogirls tutorials.

Here by default we get sqlite3 as default database Engine

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

I tried some ORM queries also, Even performed some row sql queries

At my django project I have this db.sqlite3 file

blog  db.sqlite3  env  manage.py  mysite

My Question: How to knew the schema that django created in this db.sqlite3(I knew mysql where I can see details about each database and tables,so here I just want to know more things in sqlite)

I have sqlite3 in my system and I tried .database command,but it just shows me

seq  name             file                                                      
---  ---------------  ----------------------------------------------------------
0    main 
over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Goto the folder where the database is and then

sqlite3  db.sqlite3

Then

.tables

or .schema

depending on what you want. Instead of invoking sqlite3 directly you could do

 python manage.py dbshell 

and then type the sqlite commands.

If you are working with a legacy database you can generate Django models for that using the

 python manage.py inspectdb

please see https://docs.djangoproject.com/en/3.0/ref/django-admin/#django-admin-inspectdb for additional info.

But please do yourself a favour and get a GUI database client. Life is much easier when you have one.

over 4 years ago · Santiago Trujillo Report

0

I have been stumbling around for an hour aiming to replicate DESCRIBE table inside the Django shell, and think I've cracked it. I hope this is of use to others.

In the Terminal - enter the following commands.

python3 manage.py dbshell
.tables

Find the name of the table you are looking for, then run the following commands:

.header on
.mode column
pragma table_info('table you are looking for');

Do not forget the semicolon in the last instruction.

over 4 years ago · Santiago Trujillo Report

0

You can use the following command to get the sql script for the database created.

python manage.py sqlmigrate app_label migration_name

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!