Cannot create DB in MySQL

Asked by Steve Keller on 2012-05-17

I need to setup a MySQL database for Graphite, as we will be clustering 3 servers. I set up the database following the commented examples in local_settings.py (of course I created the database first using MySQL), then ran manage.py syncdb.

This succeeds, but actually creates the database in sqlite. When I hit the graphite web page, I see the following exception:

Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py", line 101, in get_response
    request.path_info)
  File "/usr/lib/python2.7/site-packages/django/core/urlresolvers.py", line 252, in resolve
    sub_match = pattern.resolve(new_path)
  File "/usr/lib/python2.7/site-packages/django/core/urlresolvers.py", line 158, in resolve
    return ResolverMatch(self.callback, args, kwargs, self.name)
  File "/usr/lib/python2.7/site-packages/django/core/urlresolvers.py", line 164, in _get_callback
    self._callback = get_callable(self._callback_str)
  File "/usr/lib/python2.7/site-packages/django/utils/functional.py", line 124, in wrapper
    result = func(*args)
  File "/usr/lib/python2.7/site-packages/django/core/urlresolvers.py", line 91, in get_callable
    lookup_view = getattr(import_module(mod_name), func_name)
  File "/usr/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/opt/graphite/webapp/graphite/browser/views.py", line 20, in <module>
    from graphite.util import getProfile, getProfileByUsername, defaultUser, json
  File "/opt/graphite/webapp/graphite/util.py", line 55, in <module>
    defaultUser = User.objects.get(username='default')
  File "/usr/lib/python2.7/site-packages/django/db/models/manager.py", line 132, in get
    return self.get_query_set().get(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/django/db/models/query.py", line 344, in get
    num = len(clone)
  File "/usr/lib/python2.7/site-packages/django/db/models/query.py", line 82, in __len__
    self._result_cache = list(self.iterator())
  File "/usr/lib/python2.7/site-packages/django/db/models/query.py", line 273, in iterator
    for row in compiler.results_iter():
  File "/usr/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 680, in results_iter
    for rows in self.execute_sql(MULTI):
  File "/usr/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 735, in execute_sql
    cursor.execute(sql, params)
  File "/usr/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 86, in execute
    return self.cursor.execute(query, args)
  File "/usr/lib/python2.7/site-packages/MySQLdb/cursors.py", line 174, in execute
    self.errorhandler(self, exc, value)
  File "/usr/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
DatabaseError: (1146, "Table 'graphite.auth_user' doesn't exist")

I guess this is a bug, but I'm hoping an answer will be forthcoming.

We are running Graphite 0.9.10, installed via pip.

Thanks,
Steve Keller
<email address hidden>

Question information

Language:
English Edit question
Status:
Solved
For:
Graphite Edit question
Assignee:
No assignee Edit question
Solved by:
Steve Keller
Solved:
2012-05-22
Last query:
2012-05-22
Last reply:
Steve Keller (skeller-ea) said : #1

Forgot to add - if I remove the database definition from local_settings.py, Graphite works fine.

Steve Keller (skeller-ea) said : #2

Also, I tried both ways of setting the database parameters - dictionary and DATABASE_XXX values. Neither worked.

Michael Leinartas (mleinartas) said : #3

I believe this is a problem with how manage.py is loading settings.py after a recent refactor. A workaround is to run 'manage.py syncdb --settings=settings'

The bug with manage.py will be resolved before 0.9.10 is fully released

Steve Keller (skeller-ea) said : #4

Thanks Michael, that worked. However - there are still other issues.

First, and I will file a bug for this, I do not believe that it is wise for pip to install pre-releases. Here is what I just found (on my dev server):

[root@esmdev01 ~]# pip install graphite-web
Downloading/unpacking graphite-web
  Downloading graphite-web-0.9.10-pre2.tar.gz (2.1Mb): 2.1Mb downloaded

The pypi.python.org site lists 0.9.9 as the current version.

Second, I found this bug after installing the database and attempting to look at the admin pages (I will file this as well...)

...<snip>...
File "/usr/lib/python2.7/site-packages/django/core/urlresolvers.py", line 167, in _get_callback
    raise ViewDoesNotExist("Could not import %s. Error was: %s" % (mod_name, str(e)))
ViewDoesNotExist: Could not import graphite.events.views. Error was: No module named simplejson