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',
    }
}
发布了35 篇原创文章 · 获赞 61 · 访问量 16万+

猜你喜欢

转载自blog.csdn.net/woailyoo0000/article/details/103791474