Skip to content

Commit

Permalink
[IMPR] format db_hostname the same as db_name
Browse files Browse the repository at this point in the history
The current Wiki Replicas setup allows querrying any db replica from any
host since all of the wikis are one all of the hosts.
With the 2020 redesign each host will only have some wikis, so format
the hostname with the database name.

db_hostname is replaced by db_hostname_format.

Change-Id: Ife681250a279577b79ad80f7a9aa42b069ad4bb6
  • Loading branch information
JJMC89 committed Jan 22, 2021
1 parent 8ad7e25 commit 2d73643
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions pywikibot/config2.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class _ConfigurationDeprecationWarning(UserWarning):
'available_ssl_project', 'fake_user_agent', 'interwiki_contents_on_disk',
'line_separator', 'LS', 'panoramio', 'proxy', 'special_page_limit',
'sysopnames', 'use_mwparserfromhell', 'use_SSL_onlogin', 'use_SSL_always',
'db_hostname',
}
_future_variables = {'absolute_import', 'division', 'unicode_literals'}

Expand Down Expand Up @@ -689,10 +690,10 @@ def register_families_folder(folder_path):
# db_name_format can be used to manipulate the dbName of site.
#
# Example for a pywikibot running on wmflabs:
# db_hostname = 'enwiki.analytics.db.svc.eqiad.wmflabs'
# db_hostname_format = '{0}.analytics.db.svc.eqiad.wmflabs'
# db_name_format = '{0}_p'
# db_connect_file = user_home_path('replica.my.cnf')
db_hostname = 'localhost'
db_hostname_format = 'localhost'
db_username = ''
db_password = ''
db_name_format = '{0}'
Expand Down
2 changes: 1 addition & 1 deletion pywikibot/data/mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def mysql_query(query: str, params=None,
else:
credentials = {'read_default_file': config.db_connect_file}

with closing(pymysql.connect(config.db_hostname,
with closing(pymysql.connect(config.db_hostname_format.format(dbname),
db=config.db_name_format.format(dbname),
port=config.db_port,
charset='utf8',
Expand Down

0 comments on commit 2d73643

Please sign in to comment.