Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django 数据库名称和'之间的差异;名称';数据库中的参数_Django_Django Database - Fatal编程技术网

Django 数据库名称和'之间的差异;名称';数据库中的参数

Django 数据库名称和'之间的差异;名称';数据库中的参数,django,django-database,Django,Django Database,这个问题不言自明。请提供有价值的知识。谢谢 DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': 'gingr_cc', 'USER': '', 'PASSWORD': '', 'HOST': '', 'PORT'

这个问题不言自明。请提供有价值的知识。谢谢

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3', 
        'NAME': 'gingr_cc',                     
        'USER': '',
        'PASSWORD': '',
        'HOST': '',                     
        'PORT': '', 
    },
 'launchg': {     // This name
    'NAME': 'launchg',        // VS This name
    'ENGINE': 'django.db.backends.mysql',
    'USER': 'root',
    'PASSWORD': '',
    'HOST': '127.0.0.1',   
    'PORT': '3306',        
}

如果有多个数据库,则引用第二个数据库的名称是
数据库
字典中的键:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3', 
        'NAME': 'gingr_cc',                     
        'USER': '',
        'PASSWORD': '',
        'HOST': '',                     
        'PORT': '', 
    },
    'second_db': {  # This is the "friendly name" that you will use with django
        'NAME': 'launchg', # This is the name of the database on the server
        'ENGINE': 'django.db.backends.mysql',
        'USER': 'root',
        'PASSWORD': '',
        'HOST': '127.0.0.1',   
        'PORT': '3306',        
}
因此,如果要在第二个数据库中使用syncdb:

python manage.py syncdb --database=second_db
有更多关于使用的信息和示例