← Back to Django Course | Chapter 5: Migrations & Database Management | Lesson 7 of 8

Default Database के रूप में SQLite

SQLite वह database है जो Django out of the box automatically उपयोग करता है — यह सिर्फ disk पर एक single file है, इसलिए शुरू करने के लिए कुछ भी extra install करने की ज़रूरत नहीं।

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.

bash
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 नहीं है।

Note: यही exact कारण है कि SQLite नए projects के लिए default है: यह zero setup के साथ तुरंत काम करता है।

उदाहरण: 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.

bash
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 करती है।

Warning: कभी यह मत मानिए कि SQLite heavy concurrent traffic के under एक dedicated database server जैसा ही scale करता है।

उदाहरण: 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.

markup
# 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. #}
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. यह मान लेना कि SQLite सिर्फ testing के लिए अच्छा है और कभी किसी real deployment में उपयोग नहीं हो सकता, जब यह असल में कई छोटी, low-traffic sites के लिए ठीक है।
  2. app को reset करने के लिए db.sqlite3 file delete करना यह realize किए बिना कि यह permanently इसमें मौजूद real data की हर row destroy कर देता है।
  3. एक साथ कई 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 करते हैं।

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.