sqlite3 database error

32 views
Skip to first unread message

Marcus Maximus

unread,
Feb 13, 2012, 4:50:12 AM2/13/12
to Django users
Hey guys,

i am using sqlite3 for my django app. BUT I have problems installing
it. Here are my configs:

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3', # Add
'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'C:\Users\Maximus\Desktop\Webseite\Django\sqlite-shell-
win32-x86-3071000\test.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.
}
}

I tried this:

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

But I got this error:

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

Can sb pls help me?

greetings

Maximus

PS.: I created my sqlite3 file like that:

>sqlite3 test.db
...>
...>
...>);
...>Syntax error
>

Can sb show me a better way to create an empty sqlite3 db file?

Babatunde Akinyanmi

unread,
Feb 13, 2012, 7:35:09 AM2/13/12
to django...@googlegroups.com
After specifying the path to where you want your sqlite database to be
i.e db name setting, after your syncdb, the database will be created
automatically if it doesn't already exist in the path you stated.

> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

--
Sent from my mobile device

ajohnston

unread,
Feb 13, 2012, 8:03:30 AM2/13/12
to Django users
Try changing the slashes form \ to /

ajohnston

unread,
Feb 13, 2012, 8:09:08 AM2/13/12
to Django users
Sorry. To be clearer, I should have said. In your db file name:

C:\Users\Maximus\Desktop\Webseite\Django\sqlite-shell-win32-
x86-3071000\test.db

try changing the \ to /

See:
https://docs.djangoproject.com/en/dev/ref/settings/#name

Stanwin Siow

unread,
Feb 13, 2012, 8:10:24 AM2/13/12
to django...@googlegroups.com
Try this:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',  # Add
'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'test.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.
    }




Best Regards,

Stanwin Siow



ajohnston

unread,
Feb 13, 2012, 8:18:09 AM2/13/12
to Django users
Also 'Webseite' in your file path may be misspelled?
Message has been deleted

Tom Evans

unread,
Feb 13, 2012, 11:34:46 AM2/13/12
to django...@googlegroups.com
On Mon, Feb 13, 2012 at 4:01 PM, Dennis Lee Bieber
<wlf...@ix.netcom.com> wrote:

> On Mon, 13 Feb 2012 01:50:12 -0800 (PST), Marcus Maximus
> <marcus....@gmail.com> wrote:
>
>
>>        'NAME': 'C:\Users\Maximus\Desktop\Webseite\Django\sqlite-shell-
>>win32-x86-3071000\test.db',                      # Or path to database
>
>        Is that a typo? "Webseite" and not "Website"?
>

Webseite is German for web-site, so probably not.

Cheers

Tom

Reply all
Reply to author
Forward
0 new messages