时间:2021-07-01 10:21:17 帮助过:27人阅读
配置setting.py里的DATABASES项
默认使用sqllite:
DATABASES = { ‘default‘: { ‘ENGINE‘: ‘django.db.backends.sqlite3‘, ‘NAME‘: os.path.join(BASE_DIR, ‘db.sqlite3‘), } }
This example is for PostgreSQL:
DATABASES = { ‘default‘: { ‘ENGINE‘: ‘django.db.backends.postgresql‘, ‘NAME‘: ‘mydatabase‘, ‘USER‘: ‘mydatabaseuser‘, ‘PASSWORD‘: ‘mypassword‘, ‘HOST‘: ‘127.0.0.1‘, ‘PORT‘: ‘5432‘, } }
PostgreSQL可替换成其他数据库如MySQL, Oracle
参考:https://docs.djangoproject.com/en/1.11/ref/settings/#databases
Django 配置数据库
标签:highlight end mysq example post 数据 data efault oracl