I'm new to Django framework. I tried to create a simple blog by following one of the Django Girls tutorials.
Here by default, we get SQLite3 as the 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 raw SQL queries.
In my Django project, I have this db.sqlite3 file:
blog db.sqlite3 env manage.py mysite
🙋♂️ My Question: How to know the schema that Django created in this db.sqlite3
?
I know 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 the .database
command, but it just shows me:
seq name file
--- --------------- ----------------------------------------------------------
0 main
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.