1.設置Django後臺數據庫
在項目目錄setting中找到DATABASES屬性
Databases
Django officially supports the following databases:
There are also a number of database backends provided by third parties.
--連接MySQL
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': "數據庫名稱",
'USER': "root",
'PASSWORD': "woailyoo",
'HOST': "192.168.247.5",
'PORT': '3306',
'OPTIONS': {
"init_command": "SET foreign_key_checks = 0;",
}
}
}
--連接Oracle
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.oracle', 'NAME': '實例名', 'USER': 'a_user', 'PASSWORD': 'a_password', 'HOST': 'dbprod01ned.mycompany.com', 'PORT': '1540', } }