dexx1220
dexx1220

Reputation: 101

Trouble with Sqlite on Python/Django

I'm trying to learn Django and following along the Django Book tutorial and I'm getting an error when I type these lines into the Python shell:

>>> from django.db import connection
>>> cursor = connection.cursor()

Here's the traceback I get:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "C:\Python27\lib\site-packages\django\db\backends\__init__.py", line 306,
 in cursor
    cursor = self.make_debug_cursor(self._cursor())
  File "C:\Python27\lib\site-packages\django\db\backends\sqlite3\base.py", line
288, in _cursor
    self._sqlite_create_connection()
  File "C:\Python27\lib\site-packages\django\db\backends\sqlite3\base.py", line
278, in _sqlite_create_connection
    self.connection = Database.connect(**kwargs)
OperationalError: unable to open database file

Any ideas on how to solve this? On my settings.py I have DATABASES ENGINE set to: django.db.backends.sqlite3 and NAME set to: C:\Python27/PythonProjects/mysite. Thanks!

Upvotes: 2

Views: 331

Answers (1)

Oli
Oli

Reputation: 239820

I find (in modern Django) that just giving a filename like database.sqlite for the filename as the name is the best option. Django should interpret that by sticking the new database in the root folder of the project, which is perfect for my needs.

Upvotes: 1

Related Questions