[Answered ]-Using Django Sqlite in windows

1๐Ÿ‘

Use forward slashes or r'' strings to begin with.

'default': {
    # [... snip ...]
    'NAME': 'D:/database.db',
    # (or...) 'NAME': r'D:\database.db',
    # [... snip ...]
}

Additionally you need to ensure the entire directory your Sqlite file is in is writable (in this case D:/), as Sqlite needs to write its journal file next to the database file.

๐Ÿ‘คAKX

1๐Ÿ‘

This works for me

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3', 
        'NAME': 'c:/projects/blog/first.db',  
        'USER': '',                      # Not used with sqlite3.
        'PASSWORD': '',                  # Not used with sqlite3.
        'HOST': '',                      # Not used with sqlite3.
        'PORT': '',                      # Not used with sqlite3.
    }
}
๐Ÿ‘คeosorio

0๐Ÿ‘

Try using only the name of the database file (no path). By default, Django will place it in the same directory as manage.py

'default': {
    'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
    'NAME': 'database.db',                      # Or path to database file if using sqlite3.
    'USER': '',                      # Not used with sqlite3.
    'PASSWORD': '',                  # Not used with sqlite3.
    'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
    'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
}
๐Ÿ‘คjfmancilla

Leave a comment