Tutorial database problem

34 views
Skip to first unread message

phantom21

unread,
May 26, 2012, 11:38:22 PM5/26/12
to Django users
I've tried to set up the database as sqlite3. I keep getting an error
on the ENGINE line, but can't figure out why as it looks correct.

Here is the database section:


DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': '/usr/bin/sqlite3/mark.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.
}
}


And here is the error I receive:

Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/
__init__.py", line 443, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/
__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/
base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/
base.py", line 232, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/
base.py", line 371, in handle
return self.handle_noargs(**options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/
commands/syncdb.py", line 57, in handle_noargs
cursor = connection.cursor()
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/
dummy/base.py", line 15, in complain
raise ImproperlyConfigured("settings.DATABASES is improperly
configured. "
django.core.exceptions.ImproperlyConfigured: settings.DATABASES is
improperly configured. Please supply the ENGINE value. Check settings
documentation for more details.

Can anyone point out the issue here?

Thanks,

Mark

Jirka Vejrazka

unread,
May 27, 2012, 6:29:29 AM5/27/12
to django...@googlegroups.com
Hi,

you're creating your database file in /usr/bin which is intended for
system executable files, not databases etc. It's highly likely that
you don't even have write permissions there (unless you work using the
"root" account which is a big NO-NO).

Set your database file somewhere where you can write for sure, such
as /home/<myusername>/test_db.db.

You can easily find out if you have write permissions somewhere by
using the "touch" command, i.e. "touch /home/<myusername>/test_db.db -
it'll either create an empty file which means that this path is OK for
your database, or give you an error.

HTH

Jirka

phantom21

unread,
May 27, 2012, 6:55:03 AM5/27/12
to Django users
initially I'd created given the path as /home/mark/database/mark.db
but that gave me the same error so I wanted to try creating it in the
same place as sqlite3 existed, with the same results.

Mark

Fadi Samara

unread,
May 27, 2012, 6:49:38 AM5/27/12
to django...@googlegroups.com
Hi,

I'm not creating it outside the project path, I create /u01/my-project and gave it 755 permission, and have use default path for the database file to be in the same directory of the manage.py file.

I'm using a normal user (not root), but I think the Apache user does not have access to database file unless it's chmod 777.

Any help?


   Jirka

--
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.




--
Fadi Samara
+61 410 387 353

Fadi Samara

unread,
May 27, 2012, 6:56:43 AM5/27/12
to django...@googlegroups.com
so have you found any solution?

--
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.

phantom21

unread,
May 27, 2012, 10:15:20 AM5/27/12
to Django users
No. Why I'm asking. I don't see a problem with the DATABASES section
of the file, but another pair of eyes might. The error implies a
problem with the ENGINES line, but, again, I don't see it.

Mark
Message has been deleted

phantom21

unread,
May 27, 2012, 10:12:38 PM5/27/12
to Django users
See above. Initially I had tried /home/mark/database/mark.db, but got
the same error, so I tried it in the directory sqlite3 executable
resides. Got THE SAME ERROR!

The error has nothing to do with where the database resides it seems.
The error seems to indicate some issue with the ENGINES line, but I
can't see it. Why I'm asking for help. Maybe other eyes can see what
I can't.

Mark


On May 27, 5:38 pm, Dennis Lee Bieber <wlfr...@ix.netcom.com> wrote:
> On Sat, 26 May 2012 20:38:22 -0700 (PDT), phantom21 <i...@pulps1st.com>
> declaimed the following in gmane.comp.python.django.user:
>
> > I've tried to set up the database as sqlite3.  I keep getting an error
> > on the ENGINE line, but can't figure out why as it looks correct.
>
>         Not an expert but...
>
> >         'NAME': '/usr/bin/sqlite3/mark.db',  # Or path to database
> > file if using sqlite3
>
>         Why are you attempting to store the database /data/ file in a system
> protected (I'd hope) directory?
>
> --
>         Wulfraed                 Dennis Lee Bieber         AF6VN
>         wlfr...@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

ajohnston

unread,
May 28, 2012, 1:02:44 AM5/28/12
to django...@googlegroups.com
What happens if you do:

$ python manage.py shell                   ## at the bash prompt
>> import django.db.backends.sqlite3  ## in the python shell

If you get an error, you might try reinstalling django. But I'm not sure what the problem is/was. Your DATABASES code looks fine.

Gelonida N

unread,
May 28, 2012, 4:57:23 AM5/28/12
to django...@googlegroups.com
Well your DATABASES settings look fine (except of the path of the NAME
entry as others have already pointed out.
To be very sure there are no permission problems


Do you get the error already when running the command

python manage.py syncdb





For testing you could add following line as LAST line in settings.py

print 'DATABASES = %r' % DATABASES

and paste the results to your next answer.
Printing with %r has also the advantage of revealing any hidden characters.


Are you sure, that django uses the setting.py file, that you modified???

If you're not sure, than add following line as the FIRST line in settings.py
a = 1 / 0

If Django fails now with a division by zero you're sure it's using the
file you think it's using and you can remove this line again.




phantom21

unread,
May 28, 2012, 10:23:19 PM5/28/12
to Django users
OK, problem solved. The location I thought was working for django 1.4
was different than was actually the case. I'm reinstalling to a new
location and hope it will work correctly this time.

The advice on adding the divide by 0 line helped since it didn't
execute.

Thanks,

Mark
Reply all
Reply to author
Forward
0 new messages