blob: 364ecf448736ef49b2ce4d947c89ceb114532c8b [file] [log] [blame]
avm99963411e36a2020-09-27 23:32:48 +02001import pyodbc
2import configparser
3from TableParser import TableParser
4import datetime
5
6config = configparser.ConfigParser()
7config.read('config.ini')
8
9db_host = config['db']['host']
10db_database = config['db']['database']
11db_user = config['db']['user']
12db_password = config['db']['password']
13
14connection_string = (
15 'DRIVER=MySQL ODBC 8.0 ANSI Driver;'
16 'SERVER=' + db_host + ';'
17 'DATABASE=' + db_database + ';'
18 'UID=' + db_user + ';'
19 'PWD=' + db_password + ';'
20 'charset=utf8mb4;'
21)
22
23db = pyodbc.connect(connection_string)
24db.setdecoding(pyodbc.SQL_WCHAR, encoding='utf-8')
25db.setencoding(encoding='utf-8')
26
27tomorrow = datetime.date.today() + datetime.timedelta(days=1)
28
29parser = TableParser('https://fme-intranet.upc.edu/appsext/mrbs/web/day.php')
30for area in [2, 6]:
31 parser.parse(tomorrow.year, tomorrow.month, tomorrow.day, area, db)