Page MenuHomePhabricator

db_username and db_password don't work sometimes
Open, LowPublic

Description

I guess, the manual https://www.mediawiki.org/wiki/Manual:Pywikibot/MySQL#Pywikibot and comments in user-config.py should have description like:

db_username, db_password - the credentials to connect to the database, using if set db_connect_file = None

On this manual link already written. that if this variable db_connect_file is not defined or = '', then pwb by default use credentials from the .my.cnf file.
This is so. You can check in debugger, that None is necessary for using db_username/db_password. See the screenshot of PyCharm debuger:


But my edit was declined. With comment that it can also be empty or not set at all, any case user/password will be use if specified. See also discussion. Perhaps misunderstanding here.

Event Timeline

Vladis13 created this task.Jun 28 2018, 9:57 PM
Restricted Application added subscribers: pywikibot-bugs-list, Aklapper. · View Herald TranscriptJun 28 2018, 9:57 PM
Dvorapa added subscribers: zhuyifei1999, Mpaa, Dvorapa.EditedJun 28 2018, 11:00 PM

Per my understanding there should be either db_username+db_password or db_connect_file. But per @Vladis13 it seems like db_username is sometimes ignored even if no db_connect_file is given.

Probably not bug in the documentation, but in Pywikibot MySQL I think as the connect file shouldn't be used if username and password set

Dvorapa renamed this task from An amendment in documentation of Manual:Pywikibot/MySQL to db_username and db_password don't work sometimes.Jun 28 2018, 11:05 PM

Not even driver-dependent.

db_connect_file = user_home_path('.my.cnf')
if config.db_connect_file is None:
    credentials = {'user': config.db_username,
                   'passwd': config.db_password}
else:
    credentials = {'read_default_file': config.db_connect_file}

As there is always db_connect_file set in config2 (if not explicitly set to None in user-config like @Vladis13 discovered), the if should be the other way around I think: if (not) db_username:

Xqt triaged this task as Low priority.Jan 13 2019, 12:52 PM