0

私はWindows 7を使用しています。多くの問題とpython 3.3およびdjango 1.5.1の後にMysql 5.5をインストールしました。mysqlでデータベースを作成しましpython manage.py syncdbた。初めて実行すると、SyntaxError: invalid syntax (connections.py, line 36)

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'test_django',                      # Or path to database file if using sqlite3.
        # The following settings are not used with sqlite3:
        'USER': 'root',
        'PASSWORD': 'root',
        'HOST': 'localhost',                      # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
        'PORT': '3306',                      # Set to empty string for default.
    }
}

もちろん、パスワードとデータベース名は正しいです。何か案は?

編集 - connections.py は mysqldb モジュールにあり、36 行目にあります

    raise errorclass, errorvalue

トレースバックを表示するにはどうすればよいですか?

4

2 に答える 2

0

同じ Line 36 構文エラーがあり、解決しました。Mysql ドライバーと Python 3 の不一致が原因で、 http://bunwich.blogspot.com/2014/02/finally-mysql-connector-that-works-with. htmlはこれに役立ちます

また :

DATABASES = {
    'default': {
        'NAME': 'mydatabase',
        'ENGINE': 'mysql.connector.django',
        'USER': 'myuser',
        'PASSWORD': 'secretpassword',
        'OPTIONS': {
          'autocommit': True,
        },
    }
}

ENGINE はmysql.connector.djangoであり、 ではないことに注意してくださいdjango.db.backends.mysql

于 2015-03-20T03:50:27.270 に答える
0

Python 3 と互換性のある最初のバージョンである Django の最新バージョン 1.5 を使用していません。以前の Django バージョンは、Python 2.x とのみ互換性があります。

于 2013-04-15T18:28:05.633 に答える