I'm trying to call a python function that makes some queries into my django database from GNU mailman.
When mailman tries to deliver a message, it imports my python script. It later calls a function in my script to modify the message object. The error I'm getting is:
ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation \
for more details.
Here's how I'm configuring the settings, at the very top of my file:
from django.core.management import setup_environ
from mysite import settings
setup_environ(settings)
When I run python manage.py syncdb, it seems to create the database fine. Here's my database configuration:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'django_db', # Or path to database file if using sqlite3.
'USER': 'root', # Not used with sqlite3.
'PASSWORD': 'root', # 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.
}
}
Further, I've commented out the entirety of my function such that it now looks like:
def f():
return
So I don't think this has to do with the function call.
Further, I've tested the setup_environ lines in the python console and everything works as expected.
Further, when I restart GNU mailman, I believe it has to load all its scripts, which means it necessarily has to import my file. This means that these "setup_environ" lines run when I restart mailman. And it's fine -- I get no errors.
It's only when GNU mailman tries to deliver a message that I have problems.
So I'm pretty stumped. I do run the mailman restart command as sudo with additional PYTHONPATH and DJANGO_SETTINGS_MODULE environmental variables, but I've manually added to the relevant parts to my sys.path and os.environ dict, which doesn't fix the problem either. Besides, the error doesn't suggest it's a problem with the path or being unable to find the settings module.
The full stack trace is:
Jun 04 12:06:11 2012 (5249) Uncaught runner exception: settings.DATABASES is improperly configured. Please supply the ENGINE val\
ue. Check settings documentation for more details.
Jun 04 12:06:11 2012 (5249) Traceback (most recent call last):
File "/var/lib/mailman/Mailman/Queue/Runner.py", line 100, in _oneloop
msg, msgdata = self._switchboard.dequeue(filebase)
File "/var/lib/mailman/Mailman/Queue/Switchboard.py", line 173, in dequeue
redirect_list(msg, data)
File "/home/ubuntu/djcode/mysite/mysite/apps/mailman/redirect.py", line 32, in redirect_list
File "/home/ubuntu/djcode/mysite/mysite/apps/mailman/redirect.py", line 45, in _get_real_listname
from mysite.apps.common.models import CustomUser
File "/home/ubuntu/djcode/mysite/mysite/apps/common/custom_user_manager.py", line 54, in get
email_object = Email.objects.get(email=kwargs['email'])
File "/usr/local/lib/python2.6/dist-packages/django/db/models/manager.py", line 131, in get
return self.get_query_set().get(*args, **kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/db/models/query.py", line 361, in get
num = len(clone)
File "/usr/local/lib/python2.6/dist-packages/django/db/models/query.py", line 85, in __len__
self._result_cache = list(self.iterator())
File "/usr/local/lib/python2.6/dist-packages/django/db/models/query.py", line 291, in iterator
for row in compiler.results_iter():
File "/usr/local/lib/python2.6/dist-packages/django/db/models/sql/compiler.py", line 763, in results_iter
for rows in self.execute_sql(MULTI):
File "/usr/local/lib/python2.6/dist-packages/django/db/models/sql/compiler.py", line 808, in execute_sql
sql, params = self.as_sql()
File "/usr/local/lib/python2.6/dist-packages/django/db/models/sql/compiler.py", line 71, in as_sql
out_cols = self.get_columns(with_col_aliases)
File "/usr/local/lib/python2.6/dist-packages/django/db/models/sql/compiler.py", line 218, in get_columns
col_aliases)
File "/usr/local/lib/python2.6/dist-packages/django/db/models/sql/compiler.py", line 306, in get_default_columns
r = '%s.%s' % (qn(alias), qn2(field.column))
File "/usr/local/lib/python2.6/dist-packages/django/db/models/sql/compiler.py", line 49, in quote_name_unless_alias
r = self.connection.ops.quote_name(name)
File "/usr/local/lib/python2.6/dist-packages/django/db/backends/dummy/base.py", line 15, in complain
raise ImproperlyConfigured("settings.DATABASES is improperly configured. "
ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation \
for more details.
Seems you have not specified anything in your setting.py file's DATABASES dictionary.Specify the following to connect to databse successfully(as per docs),
1) ENGINE -- Either 'django.db.backends.postgresql_psycopg2', 'django.db.backends.mysql', 'django.db.backends.sqlite3' or 'django.db.backends.oracle'. Other backends are also available.
2) NAME -- The name of your database. If you're using SQLite, the database will be a file on your computer; in that case, NAME should be the full absolute path, including filename, of that file. If the file doesn't exist, it will automatically be created when you synchronize the database for the first time (see below).
3) USER -- Your database username (not used for SQLite).
4) PASSWORD -- Your database password (not used for SQLite).
5) HOST -- The host your database is on. Leave this as an empty string if your database server is on the same physical machine (not used for SQLite).
(OR) click HERE
Related
Please do not close my question again if you are not sure that the answer provide to others fit my case.
I am deploying a django app for the first time to Heroku. I used the following:
heroku run python manage.py migrate
and it returns :
Traceback (most recent call last):
File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/base/base.py", line 217, in ensure_connection
self.connect()
File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/base/base.py", line 195, in connect
self.connection = self.get_new_connection(conn_params)
File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/postgresql/base.py", line 178, in get_new_connection
connection = Database.connect(**conn_params)
File "/app/.heroku/python/lib/python3.6/site-packages/psycopg2/__init__.py", line 122, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
In my settings.py i have :
DATABASES = {
'default': dj_database_url.config(
default=config('DATABASE_URL')
)
}
and at the bottom :
try:
from .local_settings import *
except ImportError:
pass
in the local_settings.py I have :
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'newapp_development',
'USER': 'postgres',
'PASSWORD': '#####',
'HOST': 'localhost',
'PORT': '5432',
}
}
my .gitignore file looks like:
# byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
# tests and coverage
*.pytest_cache
.coverage
# database & logs
*.db
*.sqlite3
*.log
# venv
env
venv
# other
.DS_Store
# javascript
package-lock.json
staticfiles/*
!staticfiles/.gitkeep
!/core/local_settings.py
Do you know why is the error message please ?
Also, note that local_settings is added to . gitignore.
I did a few search on search engine and the responses that i found did not work for me or were not clear enough to me. This is the reason why I took the risk of asking publicly here.
Thank you for your help.
Solution found, the approach that I used works perfectly to manage two different db with two settings files.
What was wrong, was .env file which came with the template that I used. it had the following :
DATABASE_URL=jdbc:postgresql://localhost:5432/postgres
deleting this line makes it work both in production and locally.
Thank you guys for helping me eliminate the potential problems down to the main one.
And to those who downgraded my question,...not much to say actually.
Project background:
Django project, I use gunicorn to run the project, in the project, i use python socket io to process some event
Postgresql, config like this:
DATABASES['default'] = {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': xxx,
'USER': xxx,
'PASSWORD': xxx,
'HOST': 'xxx',
'PORT': '5432',
'CONN_MAX_AGE': 60 * 10, # seconds
'OPTIONS': {
'connect_timeout': 20,
},
}
the python socket io will keep a thread to process some events. so the thread has its own postgresql database connection. sometimes, I find it will throw database connection problem, like this, I don't know why the database connection isn't be closed normally
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/engineio/server.py", line 520, in _trigger_event
return self.handlers[event](*args)
File "/usr/local/lib/python2.7/site-packages/socketio/server.py", line 590, in _handle_eio_message
self._handle_event(sid, pkt.namespace, pkt.id, pkt.data)
File "/usr/local/lib/python2.7/site-packages/socketio/server.py", line 526, in _handle_event
self._handle_event_internal(self, sid, data, namespace, id)
File "/usr/local/lib/python2.7/site-packages/socketio/server.py", line 529, in _handle_event_internal
r = server._trigger_event(data[0], namespace, sid, *data[1:])
File "/usr/local/lib/python2.7/site-packages/socketio/server.py", line 558, in _trigger_event
return self.handlers[namespace][event](*args)
File "/usr/src/app/async_worker/controllers/server/event_handler.py", line 61, in on_jira_handle_from_client_retrieve
ticket = Ticket.get_ticket_by_id(ticket_id)
File "/usr/src/app/review/models/ticket.py", line 144, in get_ticket_by_id
return Ticket.objects.filter(id=ticket_id).first()
File "/usr/local/lib/python2.7/site-packages/django/db/models/query.py", line 564, in first
objects = list((self if self.ordered else self.order_by('pk'))[:1])
File "/usr/local/lib/python2.7/site-packages/django/db/models/query.py", line 250, in __iter__
self._fetch_all()
File "/usr/local/lib/python2.7/site-packages/django/db/models/query.py", line 1118, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "/usr/local/lib/python2.7/site-packages/django/db/models/query.py", line 53, in __iter__
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch)
File "/usr/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 899, in execute_sql
raise original_exception
OperationalError: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
This is what I get in the PostgreSQL log file:
LOG: could not receive data from client: Connection reset by peer
some ideas about the problem? I think if the connection keeps too long time (> CONN_MAX_AGE), the conn should be closed and set to None, but actually the connection is not null but the already closed
The error message you see is from the PostgreSQL client library.
Now both the PostgreSQL server and client complain that the other side suddenly went away, so this is almost certainly a nerwork problem.
My money is on an ill-configured firewall that drops idle connections after a while. I've always wondered if there is any valid use case to have a firewall do this...
I am trying to run Selenium tests on a Django project (1.5.4), which uses South. I think South is conflicting with my tests when I try to inject initial data with fixtures, but I'm not sure why; I appreciate any help.
According to the Django documentation, fixtures are supposed to be loaded after the first syncdb and then all migrations are applied.
Question 1) Does this take into account South migrations?? Do I need to run those separately somehow?
The error I get when I run my tests makes it seem like my South migrations are still present in the test database after the first test...but I thought each test has its own database (and migrations / fixtures) created? The first test passes / fails, but each subsequent test raises this IntegrityError:
IntegrityError: Problem installing fixture '<PROJECT_PATH>/fixtures/toy_course.json': Could not load contenttypes.ContentType(pk=8): (1062, "Duplicate entry 'south-migrationhistory' for key 'app_label'")
This South documentation and SO question seem to indicate that I need to override some type of forwards method in order to get fixtures working, but I'm not entirely sure how to apply that to a testing situation instead of production (or if that is the solution I need).
Question 2) Am I supposed to override forwards in my test setup? Where would I do it?
My relevant test code:
from django.conf import settings
from selenium import webdriver
from functional_tests.test import SeleniumTestCase
class Resources(SeleniumTestCase):
fixtures = ['toy_course.json']
def setUp(self):
self.browser = webdriver.Chrome(settings.SELENIUM_WEBDRIVER)
self.browser.implicitly_wait(3)
def tearDown(self):
self.browser.quit()
def test_main_page_renders_correctly(self):
"""
User sees a properly formatted main page
"""
self.open('/RDB/')
h3_headers = self.browser.find_elements_by_tag_name('h3')
self.assertIn(
'Complete List of Resources',
[header.text for header in h3_headers])
self.assertTrue(self.check_exists_by_id('main_table'))
self.assertTrue(self.check_exists_by_id('searchDiv'))
self.assertTrue(self.check_exists_by_class_name('tablesorter'))
Thanks!
UPDATE
So per Alex's suggestion below and this South doc, I added this line to my settings.py:
SOUTH_TESTS_MIGRATE = False
But I am now getting 8 of 8 Errors (before I was getting 1 pass/fail on the first test, and then 7 Errors). The full error for a single test is below:
======================================================================
ERROR: test_table_sorts_on_click (functional_tests.tests.main_resources.Resources)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/<PATH TO VIRTUAL ENV>/virtual_environments/relate/lib/python2.7/site-packages/django/test/testcases.py", line 259, in __call__
self._pre_setup()
File "/<PATH TO VIRTUAL ENV>/virtual_environments/relate/lib/python2.7/site-packages/django/test/testcases.py", line 479, in _pre_setup
self._fixture_setup()
File "/<PATH TO VIRTUAL ENV>/virtual_environments/relate/lib/python2.7/site-packages/django/test/testcases.py", line 518, in _fixture_setup
**{'verbosity': 0, 'database': db_name, 'skip_validation': True})
File "/<PATH TO VIRTUAL ENV>/virtual_environments/relate/lib/python2.7/site-packages/django/core/management/__init__.py", line 161, in call_command
return klass.execute(*args, **defaults)
File "/<PATH TO VIRTUAL ENV>/virtual_environments/relate/lib/python2.7/site-packages/django/core/management/base.py", line 255, in execute
output = self.handle(*args, **options)
File "/<PATH TO VIRTUAL ENV>/virtual_environments/relate/lib/python2.7/site-packages/django/core/management/commands/loaddata.py", line 193, in handle
obj.save(using=using)
File "/<PATH TO VIRTUAL ENV>/virtual_environments/relate/lib/python2.7/site-packages/django/core/serializers/base.py", line 165, in save
models.Model.save_base(self.object, using=using, raw=True)
File "/<PATH TO VIRTUAL ENV>/virtual_environments/relate/lib/python2.7/site-packages/django/db/models/base.py", line 626, in save_base
rows = manager.using(using).filter(pk=pk_val)._update(values)
File "/<PATH TO VIRTUAL ENV>/virtual_environments/relate/lib/python2.7/site-packages/django/db/models/query.py", line 605, in _update
return query.get_compiler(self.db).execute_sql(None)
File "/<PATH TO VIRTUAL ENV>/virtual_environments/relate/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 1014, in execute_sql
cursor = super(SQLUpdateCompiler, self).execute_sql(result_type)
File "/<PATH TO VIRTUAL ENV>/virtual_environments/relate/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 840, in execute_sql
cursor.execute(sql, params)
File "/<PATH TO VIRTUAL ENV>/virtual_environments/relate/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 122, in execute
six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e.args)), sys.exc_info()[2])
File "/<PATH TO VIRTUAL ENV>/virtual_environments/relate/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 120, in execute
return self.cursor.execute(query, args)
File "/<PATH TO VIRTUAL ENV>/virtual_environments/relate/lib/python2.7/site-packages/MySQLdb/cursors.py", line 201, in execute
self.errorhandler(self, exc, value)
File "/<PATH TO VIRTUAL ENV>/virtual_environments/relate/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
raise errorclass, errorvalue
IntegrityError: Problem installing fixture '/<PATH TO PROJECT>/RDB/fixtures/toy_course.json': Could not load contenttypes.ContentType(pk=8): (1062, "Duplicate entry 'south-migrationhistory' for key 'app_label'")
The command I ran:
$ python manage.py test functional_tests
I'm not quite sure if I made the problem better, worse, or the same, but I seem to be more in-line with the documentation...
Thanks!
UPDATE #2 -- with solution
So a couple of other pages that helped me figure it out (in addition to Alex's pointer to the South doc). First, this person had a similar issue, and solved it using the SOUTH_TESTS_MIGRATE = False statement. So half my solution was to include that.
The second half of my solution was to fix my fixture document. I was dumping everything into my fixture with:
$ python manage.py datadump > RDB/fixtures/toy-course.json
This is, apparently, a bad way to do fixtures it with South--because it also dumps the South migration tables into the fixture. The post above shows the blogger using app-specific fixtures (which are also talked about in this SO post), and that was the key to getting my fixtures to work. The Django docs on fixtures do show the optional parameters to dump just an app, but I didn't know ignoring them would cause South to conflict. So the second half of my solution was to create my fixture to be app-specific:
$ python manage.py datadump RDB > RDB/fixtures/toy-course.json
And my tests now run fine (slow, but probably a different issue)!
Your test database is created using South migrations by default. Set SOUTH_TESTS_MIGRATE = False in your settings.py, quote from docs:
If this is False, South’s test runner integration will make the test
database be created using syncdb, rather than via migrations (the
default).
Working on the Django tutorial at the moment and got this error when I tried:
python manage.py syncdb
Using sqlite3
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Library/Python/2.6/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
utility.execute()
File "/Library/Python/2.6/site-packages/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Python/2.6/site-packages/django/core/management/base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Library/Python/2.6/site-packages/django/core/management/base.py", line 232, in execute
output = self.handle(*args, **options)
File "/Library/Python/2.6/site-packages/django/core/management/base.py", line 371, in handle
return self.handle_noargs(**options)
File "/Library/Python/2.6/site-packages/django/core/management/commands/syncdb.py", line 57, in handle_noargs
cursor = connection.cursor()
File "/Library/Python/2.6/site-packages/django/db/backends/__init__.py", line 306, in cursor
cursor = self.make_debug_cursor(self._cursor())
File "/Library/Python/2.6/site-packages/django/db/backends/sqlite3/base.py", line 281, in _cursor
self._sqlite_create_connection()
File "/Library/Python/2.6/site-packages/django/db/backends/sqlite3/base.py", line 271, in _sqlite_create_connection
self.connection = Database.connect(**kwargs)
sqlite3.OperationalError: unable to open database file
My settings.py file reads:
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': '/Users/username/django_tutorial/mysite',
Anyone know the problem here? it seems like I am putting in the complete file directory, but the databases still couldn't be created? ):
You should use the path to the file, including the file name:
'NAME': '/Users/username/django_tutorial/mysite/data.sqlite',
You can also just give it the file name:
'NAME': 'data.sqlite',
In that case it will be created in the same directory than the one from which you run manage.py.
The best practice is to pass an absolute path, but to ensure this absolute path is created relatively to the settings file. E.G:
import os
SETTINGS_DIR = os.path.dirname(os.path.abspath(__file__))
Then latter:
'NAME': os.path.join(SETTINGS_DIR, 'data.sqlite'),
Remember that the settings file is a Python file, and that you can use Python code in it.
There is a list of Django newbie mistakes on project's wiki. See this entry: https://code.djangoproject.com/wiki/NewbieMistakes#DjangosaysUnabletoOpenDatabaseFilewhenusingSQLite3
This specific error is common mistake among Django's newbies. See detailed description below.
PROBLEM
You're using SQLite3, your DATABASE_NAME is set to the
database file's full path, the database file is writeable by Apache,
but you still get the above error.
SOLUTION
Make sure Apache can also write to the parent directory of
the database. SQLite needs to be able to write to this directory.
Make sure each folder of your database file's full path does not start
with number, eg. /www/4myweb/db (observed on Windows 2000).
If DATABASE_NAME is set to something like
'/Users/yourname/Sites/mydjangoproject/db/db', make sure you've
created the 'db' directory first.
Make sure your /tmp directory is world-writable (an unlikely cause as
other thing on your system will also not work). ls /tmp -ald should
produce drwxrwxrwt ....
Make sure the path to the database specified in settings.py is a full
path.
If you working on windows make also sure that you have the path to the
db directory written with double backlashes
'C:\\django\\sqlite\\django.db'
i dont think you need the full path for the name, just put the file name ie "my_db.db". that is assuming you have sqlite3 installed.
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 ?
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
This can also happen if your database name is the same as your project name. To fix it just change the name of your db e.g. by adding a .db to the NAME. So if your DATABASE NAME in settings.py was 'epic_project' change it to 'epic_project.db'
Long and boring explanation:
If you start your project by running:
django startproject epic_project
your folder structure will be like this:
/path/to/epic_project/
manage.py
epic_project/
settings.py
if then in your settings.py you set your database as:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'epic_project',
...
}
}
when
python manage.py syncdb
runs it tries to open or create a sqlite db file at /path/to/epic_project/epic_project, but there is a directory there, so it says "oh ok the path exists already, let's open it as an sqlite db", unfortunately for sqlite it's a directory and not a DB, so it cries and django presents these tears to you as "sqlite3.OperationalError: unable to open database file"
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?
For Google's sake:
The path to the database must be the full path to the file --- not just the directory where the file lives.
I had the same problem on Windows then realized that syncdb would not create the specified folder if it didn't already exist. I had specified c:/mysite/db/sqlite3.db in settings but the /db/ folder didn't exist. Created it in terminal then re-ran syncdb successfully.
I had the same problem two days ago. I solved it by setting the 'NAME' in the DATABASE dictionary (settings.py) to the absolute path.
For example.
settings.py
DATABASES = {
'default' : {
'ENGINE' : 'django.db.backends.sqlite3',
'NAME' : DATABASE_PATH,
}
}
here you can set the DATABASE_PATH at the top of the settings.py as such
(Not sure if this will work for windows)
SETTINGS_DIR = os.path.dirname(__file__)
PROJECT_PATH = os.path.abspath(os.path.join(SETTINGS_DIR, os.pardir))
DATABASE_PATH = os.path.abspath(os.path.join(PROJECT_PATH, 'your-database-name'))
For Windows you might have to use the replace method. (Not sure .. But you can try it out as follows)
PROJECT_PATH = os.path.abspath(os.path.join(SETTINGS_DIR, os.pardir).replace('\\', '/'))
Same goes for the DATABASE_PATH.
PS. Correct me if I am wrong.
Similar to answer from user104264 - different perspective...
Currently following the YouTube tutorial I had the same error. Seems to me while running the manage.py in a virtualenv django project directory ...path to virtual env.../django_project/, the database name inside /myapp/settings.py was simply 'storage.db' so
(django-v)...path to virtual env project.../django_project/>python manage.py syncdb
created ...path to virtual env project.../django_project/storage.db
-Bill
If you are specifying a full path to db file and are still having issues, try putting an r before the string.
ie.
r'C:\home\usr\mysite\sqlite3.db'
The problem I was running into was a bootstrapping issue where some model lookups were being done at import (outside of any class or function). Per the docs, this is a bad idea.