1

我可以从本地机器连接到 Google Cloud SQL 服务:

    $ python manage.py syncdb

此命令使用 django 模型在 Google Cloud SQL 上创建所需的数据库表。(我的数据库设置指向 Cloud SQL 数据库设置)但是当我发出dbshel ​​l 命令时出现错误:

$ python manage.py dbshell

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 196, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 232, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/dbshell.py", line 21, in handle
    connection.client.runshell()
  File "/usr/local/google_appengine/google/storage/speckle/python/django/backend/client.py", line 47, in runshell
    from google.storage.speckle.python.tool import google_sql
  File "/usr/local/google_appengine/google/storage/speckle/python/tool/google_sql.py", line 53, in <module>
    from grizzled import db
ImportError: No module named grizzled

是否可以在 Cloud SQL 上运行 ./manage.py dbshel​​l?

4

1 回答 1

0

I had the same issue. Solved it by adding the required google_appengine libraries to my PYTHONPATH.

export PYTHONPATH="$PYTHONPATH:/path/to/google_appengine:/path/to/google_appengine/lib/django_1_5:/path/to/google_appengine/lib/grizzled:/path/to/google_appengine/lib/prettytable:/path/to/google_appengine/lib/sqlcmd:/path/to/google_appengine/lib/enum"

I have to do this everytime I want to connect to the Cloud SQL.

于 2013-11-02T21:03:24.790 回答