Django學習筆記----設置數據庫

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',
    }
}

 

 

 

發佈了33 篇原創文章 · 獲贊 59 · 訪問量 15萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章