如何使用django-sql-explorer配置EXPLORER_CONNECTION_NAME

问题描述 投票:1回答:1

我正在使用django-sql-explorer,我在setting.py有三个数据库连接。

我在setting.py中有以下配置:

INSTALLED_APPS = (
    ...
    'explorer',
    ...
)
EXPLORER_CONNECTIONS = {
    'Default': 'readonly',
}
EXPLORER_DEFAULT_CONNECTION = 'readonly'

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'django2',
        'OPTIONS': {
            'init_command': "SET sql_mode='STRICT_TRANS_TABLES'"
        },
        'USER': 'root',
        'PASSWORD': 'bazaar360',
        'HOST': 'demodb.birdeye.com',
        'PORT': '3306'
    },
    'integrationdb2': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'django1',
        'OPTIONS': {
            'init_command': "SET sql_mode='STRICT_TRANS_TABLES'"
        },
        'USER': 'root',
        'PASSWORD': 'bazaar360',
        'HOST': 'demodb.birdeye.com',
        'PORT': '3306'
    },
    'integrationdb3': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'django',
        'OPTIONS': {
            'init_command': "SET sql_mode='STRICT_TRANS_TABLES'"
        },
        'USER': 'root',
        'PASSWORD': 'bazaar360',
        'HOST': 'demodb.birdeye.com',
        'PORT': '3306'
    }
}

urls.py,我补充说:

...
url(r'^explorer/', include('explorer.urls')),
...

我想在那里运行查询,但在运行所述查询时遇到异常。我只是想了解如何通过q​​azxswpoi值。

django python-3.x django-rest-framework django-views
1个回答
1
投票

在设置文件中使用以下代码。

EXPLORER_CONNECTION_NAME
© www.soinside.com 2019 - 2024. All rights reserved.