SQlite3 syncdb error

Discussion in 'Web Design and Development' started by Nsutton, Apr 22, 2010.

  1. Nsutton macrumors member

    Nsutton

    Joined:
    Dec 29, 2009
    Location:
    6 Feet Under
    #1
    I was using Django and Sqlite3.
    Code:
    Last login: Thu Apr 22 06:50:43 on ttys001
    noah-suttons-macbook-pro:~ NSutton$ cd /Users/NSutton/webpoll
    noah-suttons-macbook-pro:webpoll NSutton$ python manage.py syncdb
    Traceback (most recent call last):
      File "manage.py", line 11, in <module>
        execute_manager(settings)
      File "/Library/Python/2.6/site-packages/django/core/management/__init__.py", line 362, in execute_manager
        utility.execute()
      File "/Library/Python/2.6/site-packages/django/core/management/__init__.py", line 303, in execute
        self.fetch_command(subcommand).run_from_argv(self.argv)
      File "/Library/Python/2.6/site-packages/django/core/management/base.py", line 195, in run_from_argv
        self.execute(*args, **options.__dict__)
      File "/Library/Python/2.6/site-packages/django/core/management/base.py", line 222, in execute
        output = self.handle(*args, **options)
      File "/Library/Python/2.6/site-packages/django/core/management/base.py", line 351, in handle
        return self.handle_noargs(**options)
      File "/Library/Python/2.6/site-packages/django/core/management/commands/syncdb.py", line 49, in handle_noargs
        cursor = connection.cursor()
      File "/Library/Python/2.6/site-packages/django/db/backends/__init__.py", line 81, in cursor
        cursor = self._cursor()
      File "/Library/Python/2.6/site-packages/django/db/backends/sqlite3/base.py", line 170, in _cursor
        self.connection = Database.connect(**kwargs)
    sqlite3.OperationalError: unable to open database file
    noah-suttons-macbook-pro:webpoll NSutton$ 
    following the tutorial on django. It gave me an error.
    I made my database file in terminal with
    Code:
    sqlite3 webpoll.db
    Im a allaround N00b
     
  2. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #2
    I'd check the permissions set to the DB file. There could be a potential compatibility issue too for SQLite3 DB format. I haven't used it with Python yet.
     
  3. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #3
    Have you set the correct settings in the settings.py file for a SQlite database? Remember that an SQlite database takes a full path for the database name rather than just the name of the file.

    Django will create the database for you automatically.
     
  4. Nsutton thread starter macrumors member

    Nsutton

    Joined:
    Dec 29, 2009
    Location:
    6 Feet Under
    #4
    Code:
    # Django settings for webpoll project.
    
    DEBUG = True
    TEMPLATE_DEBUG = DEBUG
    
    ADMINS = (
        # ('Your Name', 'your_email@domain.com'),
    )
    
    MANAGERS = ADMINS
    
    DATABASE_ENGINE = 'sqlite3'    # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
    DATABASE_NAME = '/User/NSutton/poll.db'# Or path to database file if using sqlite3.
    DATABASE_USER = ''             # Not used with sqlite3.
    DATABASE_PASSWORD = ''         # Not used with sqlite3.
    DATABASE_HOST = ''             # Set to empty string for localhost. Not used with sqlite3.
    DATABASE_PORT = ''             # Set to empty string for default. Not used with sqlite3.
    
    # Local time zone for this installation. Choices can be found here:
    # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
    # although not all choices may be available on all operating systems.
    # If running in a Windows environment this must be set to the same as your
    # system time zone.
    TIME_ZONE = 'America/Chicago'
    
    # Language code for this installation. All choices can be found here:
    # http://www.i18nguy.com/unicode/language-identifiers.html
    LANGUAGE_CODE = 'en-us'
    
    SITE_ID = 1
    
    # If you set this to False, Django will make some optimizations so as not
    # to load the internationalization machinery.
    USE_I18N = True
    
    # Absolute path to the directory that holds media.
    # Example: "/home/media/media.lawrence.com/"
    MEDIA_ROOT = ''
    
    # URL that handles the media served from MEDIA_ROOT. Make sure to use a
    # trailing slash if there is a path component (optional in other cases).
    # Examples: "http://media.lawrence.com", "http://example.com/media/"
    MEDIA_URL = ''
    
    # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
    # trailing slash.
    # Examples: "http://foo.com/media/", "/media/".
    ADMIN_MEDIA_PREFIX = '/media/'
    
    # Make this unique, and don't share it with anybody.
    SECRET_KEY = '+w_g#&+-mxratvxzsis9@dby7fp0!gfgsep3dyoehss$)a#@&q'
    
    # List of callables that know how to import templates from various sources.
    TEMPLATE_LOADERS = (
        'django.template.loaders.filesystem.load_template_source',
        'django.template.loaders.app_directories.load_template_source',
    #     'django.template.loaders.eggs.load_template_source',
    )
    
    MIDDLEWARE_CLASSES = (
        'django.middleware.common.CommonMiddleware',
        'django.contrib.sessions.middleware.SessionMiddleware',
        'django.contrib.auth.middleware.AuthenticationMiddleware',
    )
    
    ROOT_URLCONF = 'webpoll.urls'
    
    TEMPLATE_DIRS = (
        # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
        # Always use forward slashes, even on Windows.
        # Don't forget to use absolute paths, not relative paths.
    )
    
    INSTALLED_APPS = (
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.sites',
    )
    Anything wrong here?
     
  5. Nsutton thread starter macrumors member

    Nsutton

    Joined:
    Dec 29, 2009
    Location:
    6 Feet Under
    #5
    It was a fail on my part.

    When using SQlite you don't make the database file it create it for you. I screwed it up by making it before hand..
     

Share This Page