django 实用工具dj-database-url 快速配置数据库

dj-database-url Github>>>

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
... ... ...
posted @ 2018-05-03 21:10  不专业的专业  阅读(929)  评论(0编辑  收藏  举报