tags:

views:

467

answers:

2

I'm running ubuntu 9.04 32b and got django from Synaptics. My settings.py is configured for a sqlite3 database.

I've been through this tutorial and got the following error when trying to run the command python manage.py syncdb :

Traceback (most recent call last):
  File "manage.py", line 11, in 
    execute_manager(settings)
  File "/usr/local/lib/python2.6/dist-packages/django/core/management/__init__.py", line 340, in execute_manager
    utility.execute()
  File "/usr/local/lib/python2.6/dist-packages/django/core/management/__init__.py", line 295, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.6/dist-packages/django/core/management/base.py", line 192, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/local/lib/python2.6/dist-packages/django/core/management/base.py", line 219, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.6/dist-packages/django/core/management/base.py", line 348, in handle
    return self.handle_noargs(**options)
  File "/usr/local/lib/python2.6/dist-packages/django/core/management/commands/syncdb.py", line 51, in handle_noargs
    cursor = connection.cursor()
  File "/usr/local/lib/python2.6/dist-packages/django/db/backends/__init__.py", line 56, in cursor
    cursor = self._cursor(settings)
  File "/usr/local/lib/python2.6/dist-packages/django/db/backends/sqlite3/base.py", line 145, in _cursor
    self.connection = Database.connect(**kwargs)
sqlite3.OperationalError: unable to open database file

Do anyone have a clue on my problem ?

+1  A: 

might be a permission problem, does your user have sufficient right to write on the folder? for example if you do

sudo python manage.py syncdb

instead, does it work?

oykuo
+5  A: 

In settings.py are you using a relative path to the sqlite file?

If you are, try changing that to an absolute path.

i.e. instead of:

~/project/mydata.db

use

/home/user/project/mydata.db
JosefAssad
This solves my problem.Thx.
This is almost always the problem. Python doesn't do path expansion when it reads these.
MattK