2012-02-13 13 views
0

django新手Django - 幫助。 django沒有按預期創建sqlite數據庫文件

以下教程1.還查找了堆棧溢出的所有相關問題。認爲這是一個絕對路徑問題......但絕對路徑似乎是正確的。下面是settings.py。有任何想法嗎?

MANAGERS = ADMINS 

DATABASES = { 
    'default': { 
     'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. 
     'NAME': 'Users/Leerix/cars/carfilter/database/temp.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. 
    } 

以下是我收到的錯誤。已經在這個幾個小時了,找不到這個bug。任何幫助是極大的讚賞。 THX

python manage.py syncdb 
Traceback (most recent call last): 
    File "manage.py", line 9, in <module> 
    execute_from_command_line(sys.argv) 
    File "/Library/Python/2.5/site-packages/django/core/management/__init__.py", line 420, in execute_from_command_line 
    utility.execute() 
    File "/Library/Python/2.5/site-packages/django/core/management/__init__.py", line 359, in execute 
    self.fetch_command(subcommand).run_from_argv(self.argv) 
    File "/Library/Python/2.5/site-packages/django/core/management/base.py", line 196, in run_from_argv 
    self.execute(*args, **options.__dict__) 
    File "/Library/Python/2.5/site-packages/django/core/management/base.py", line 232, in execute 
    output = self.handle(*args, **options) 
    File "/Library/Python/2.5/site-packages/django/core/management/base.py", line 371, in handle 
    return self.handle_noargs(**options) 
    File "/Library/Python/2.5/site-packages/django/core/management/commands/syncdb.py", line 57, in handle_noargs 
    cursor = connection.cursor() 
    File "/Library/Python/2.5/site-packages/django/db/backends/__init__.py", line 306, in cursor 
     cursor = self.make_debug_cursor(self._cursor()) 
     File "/Library/Python/2.5/site-packages/django/db/backends/sqlite3/base.py", line 259, in _cursor 
     self.connection = Database.connect(**kwargs) 
sqlite3.OperationalError: unable to open database file 

回答

2

也許你的意思是使用絕對路徑(一個開始/),而不是相對路徑。

+0

謝謝。 /開始是問題.... – Leerix 2012-02-13 07:13:12

1

刪除該位置的數據庫文件。此外,從用戶開始的路徑並不是絕對的(是否?)確保您是否在以驅動器號開頭的Windows上。 (C:\)