Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

366
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda