[Django] #31969: 'database' option in conf file not working

13 views
Skip to first unread message

Django

unread,
Aug 31, 2020, 11:54:24 AM8/31/20
to django-...@googlegroups.com
#31969: 'database' option in conf file not working
-----------------------------------------+------------------------
Reporter: komaljeet | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 3.1
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
I am assumimg this is a bug since as per docs, we should be able to use
'database' in conf file.
It its not a bug, please close the ticket.

https://docs.djangoproject.com/en/3.1/ref/databases/#mysql-notes

Putting 'database' in conf file does not work, exception raised is:
django.db.utils.InternalError: (1046, 'No database selected')

DB_CONF_PATH = /path/to/conf/file
[client]

database = xxxxx
host =xxxxx
user = xxxxxxx
password = xxxxxx
default-character-set = utf8

But putting it settings.DATABASES dict works.
{{{
DATABASES = {
'default': {
'ENGINE': 'mysql_cymysql',
'OPTIONS': {
'read_default_file': DB_CONF_PATH,

},
'NAME' : 'xxxxxx'
}
}
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/31969>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 1, 2020, 12:39:56 AM9/1/20
to django-...@googlegroups.com
#31969: 'database' option in conf file not working
-------------------------------------+-------------------------------------
Reporter: komaljeet | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: 3.1
(models, ORM) | Resolution:
Severity: Normal | worksforme

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* status: new => closed
* resolution: => worksforme
* component: Uncategorized => Database layer (models, ORM)


Comment:

It works for me with [https://docs.djangoproject.com/en/3.1/ref/databases
/#connecting-to-the-database the configuration described in docs]:

- `settings.py`:
{{{
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'OPTIONS': {
'read_default_file': '/django/tests/mysql.cnf',
}
}
}
}}}

- `/django/tests/mysql.cnf`
{{{
[client]
database = NAME
user = USER
password = PASSWORD
default-character-set = utf8
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/31969#comment:1>

Reply all
Reply to author
Forward
0 new messages