django从配置文件中读取数据库信息

创建配置文件my.cnf

[client]
database=django_db user=root
password=123456
host=127.0.0.1
port=3306

settings.py

DATABASES = {
  'default': {
    'ENGINE': 'django.db.backends.sqlite3',
    'OPTIONS': {'read_default_file': 'utils.db.my.cnf'}
  }
}
posted @ 2023-10-22 16:52  我在路上回头看  阅读(54)  评论(0编辑  收藏  举报