Default Database के रूप में SQLite
Database कहां रहता है
एक freshly created Django project अपनी SQLite database को db.sqlite3 नाम की एक single file के रूप में store करता है जो project के root folder में manage.py के ठीक बगल में रहती है।
उदाहरण: Where the Database Lives
Running migrate the first time creates db.sqlite3 right next to manage.py — ls afterward confirms the file now exists.
python manage.py migrate
ls db.sqlite3
⚠️ Run this in your own terminal or Node.js environment.
Install करने के लिए कोई Server नहीं
PostgreSQL या MySQL के विपरीत, SQLite एक separate background process के रूप में नहीं चलता — Django का database driver file को directly read और write करता है, इसलिए start या configure करने के लिए कोई server नहीं है।
उदाहरण: No Server to Install
Running migrate for the first time both creates the db.sqlite3 file and fills it with Django's built-in tables — no separate installation step required.
python manage.py migrate
# creates db.sqlite3 automatically if it doesn't exist yet
⚠️ Run this in your own terminal or Node.js environment.
SQLite से आगे कब जाएं
SQLite एक समय में एक writer को अच्छी तरह handle करता है, जो development और छोटी sites के लिए ठीक है, लेकिन कई simultaneous users वाली एक busier production site आमतौर पर बेहतर concurrent write performance के लिए PostgreSQL में switch करती है।
उदाहरण: When to Move Beyond SQLite
This is the exact DATABASES setting a new Django project ships with — nothing needs to be added for SQLite to work.
# settings.py excerpt using SQLite (the default)
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
{# Django-only code -- models.py/views.py/urls.py/settings.py
snippets, or template markup using Django template tags/variables
-- can't run standalone via Judge0 or the browser preview, since
it needs a real Django project. Only this course's pure-Python
examples (example_lang == 'python', no Django imports) are
actually runnable, so those still get the button below. #}
- यह मान लेना कि SQLite सिर्फ testing के लिए अच्छा है और कभी किसी real deployment में उपयोग नहीं हो सकता, जब यह असल में कई छोटी, low-traffic sites के लिए ठीक है।
- app को reset करने के लिए db.sqlite3 file delete करना यह realize किए बिना कि यह permanently इसमें मौजूद real data की हर row destroy कर देता है।
- एक साथ कई servers से वही SQLite file access करने की कोशिश करना, जिसे SQLite heavy concurrent writes के under अच्छी तरह handle करने के लिए designed नहीं है।
- SQLite पूरी database को एक file में store करता है, आमतौर पर db.sqlite3।
- इसे किसी separate database server की ज़रूरत नहीं — Django directly file से बात करता है।
- यह एक नए project की settings.py में default ENGINE है, तुरंत उपयोग के लिए ready।
- यह learning और छोटे projects के लिए बहुत अच्छा है, लेकिन बड़े production apps अक्सर PostgreSQL में move करते हैं।
Chapter Quiz — Complete all 8 topics to unlock
0/8 topics done
Complete these topics first: