Page MenuHomePhabricator

db_username and db_password don't work sometimes
Open, LowPublic


I guess, the manual and comments in 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:

pwb_mysql_error.jpeg (735×1 px, 251 KB)

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

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}
    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

@Dvorapa the db_connect_file is also set in the , Is the update of @zhuyifei1999 code been done in the ?

@Ngwebecky96: Hi and welcome! Please investigate, and try yourself. :) Also see - thanks a lot!