#!/usr/bin/python3 """Updates the wrreportcache table (by calling wrpylib.wrmwcache.update_wrreportcache()). Can be used in a python session or at the command line. Command line usage: $ python updatewrreportcache.py inifile1.ini ... One or more .ini configuration files can be given. At the end, the following entries have to be present: [mysql] host=localhost dbname=philipp_winterrodeln_wiki user_name=philipp_www user_pass=YYYYYY """ import argparse import configparser from sqlalchemy.engine import create_engine import wrpylib.wrmwcache def update_wrreportcache(inifile): """ :param inifile: filename of an .ini file or a list of .ini files. """ config = configparser.ConfigParser() config.read(inifile) host = config.get('mysql', 'host') dbname = config.get('mysql', 'dbname') user = config.get('mysql', 'user_name') passwd = config.get('mysql', 'user_pass') engine = create_engine(f'mysql://{user}@{host}:3306/{dbname}?passwd={passwd}&charset=utf8mb4') wrpylib.wrmwcache.update_wrreportcache(engine.connect()) if __name__ == '__main__': parser = argparse.ArgumentParser(description='Updates the wrreportcache table.') parser.add_argument('inifile', nargs='+', help='inifile.ini, see: https://www.winterrodeln.org/trac/wiki/ConfigIni') args = parser.parse_args() update_wrreportcache(args.inifile)