0

Current System: Windows XP / Windows 7 (problem occuring for both)

After following the guidelines for deployment from the following:

https://devcenter.heroku.com/articles/python

and by testing by using a simple poll application I am successfully able to push the application through heorku except that after checking the logs the following error appears:

2012-04-27T08:14:42+00:00 app[web.1]: django.core.exceptions.ImproperlyConfigure
d: Error loading either pysqlite2 or sqlite3 modules (tried in that order): No m
odule named _sqlite3

This also occurs when attempting to sync the database.

Here is the current configuration of the database in the settings.py file:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'database.sqlite', # 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 am aware is it a sqlite3 database, and I have been told that it should still allow heroku to deploy the app without any errors. I have followed through using the following potential solutions that are related to this problem:

No module named _sqlite3 How do I set up SQLite with a Django project? http://groups.google.com/group/django-users/browse_thread/thread/185f981f432346f1

Any help will be appreciated! Please let me know if additional Information is needed.

Community
  • 1
  • 1
JavaCup
  • 15
  • 5
  • A better question is: why are you trying to use sqlite for your deployment? It's good for development, but if you hope to have more than 1-2 users browsing your site at any given time, you need to move on to a big-boy database. – Chris Pratt Apr 27 '12 at 14:56

2 Answers2

1

Heroku does not support sqlite, since it only provides a read-only filesystem.

Burhan Khalid
  • 169,990
  • 18
  • 245
  • 284
  • no it doesn't but you can leave your settings on sqlite3 and heroku will automatically add the postgres config, which is why it is confusing to get the error above ... – Sam Joseph Apr 27 '12 at 11:09
0

I had the same error with the settings file. Looking through the Heroku logs, it turned out that my settings.py file was failing for various reasons. Once I fixed those issues, Django stopped complaining about missing database settings.

One of the things that caused this issue was a monkey patch I was using to allow sub-selects as tables in QuerySet extra(). This patch is at the end of my settings file.

# Override default behaviour of compiler to quote table names when table name is a sub-query
from django.db.models.sql.compiler import SQLCompiler
_quote_name_unless_alias = SQLCompiler.quote_name_unless_alias
SQLCompiler.quote_name_unless_alias = lambda self,name: name if name.startswith('(') else _quote_name_unless_alias(self,name)

This patch apparently requires that DATABASES already be correctly specified at that point. Since Heroku appends the magic DATABASES configuration to the end of the settings file (i.e. after the monkey patch), I had to manually insert their configuration above my monkey patch.

Nathan
  • 1,418
  • 16
  • 32