django之sqlite3常见错误

2023-01-31 01:01:57 django 错误 常见

 如果错误的最后一行是

Django.core.exceptions.ImproperlyConfigured: Error loading either pysqlite2 or sqlite3 modules (tried in that order): No module named _sqlite3


则可以试一下命令

 

wget Http://pysqlite.Googlecode.com/files/pysqlite-2.6.3.tar.gz
tar -xzf pysqlite-2.6.3.tar.gz

cd pysqlite
python setup.py build_static install

如果打名令Python manage.py syncdb 之后还有错误那么可以试一下下面的操作

将setting 中的 DATABASES改成如下

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


这些是我遇到的问题,仅供参考

相关文章