django 实用工具dj-database-url 快速配置数据库
程序员文章站
2022-07-24 21:12:09
"dj database url " django快速配置多种数据库 Configure your database in from : Engine | Django Backend | URL | | PostgreSQL | django.db.backends.postgresql_psyc ......
django快速配置多种数据库
$ pip install dj-database-url
Configure your database in settings.py
from DATABASE_URL
:
import dj_database_url DATABASES = { 'default': dj_database_url.config(default="postgres:///channels-example", conn_max_age=500) }
Engine | Django Backend | URL |
---|---|---|
PostgreSQL | django.db.backends.postgresql_psycopg2 | postgres://USER:PASSWORD@HOST:PORT/NAME |
MySQL | django.db.backends.mysql | mysql://USER:PASSWORD@HOST:PORT/NAME?init_command=SET sql_mode=STRICT_TRANS_TABLES |
SQLite | django.db.backends.sqlite3 | sqlite:////full/path/to/your/database/file.sqlite |
... | ... | ... |
下一篇: Mysql系列-数据库