Milimetric has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/365687 )
Change subject: Update code to work with MySQLDb 1.3.7
......................................................................
Update code to work with MySQLDb 1.3.7
Some breaking changes in cursors and connections seem to have happened
since the last version we wrote this code for
Change-Id: I1799991823f3cc026551f9d86873f3614a276678
---
M geowiki/mysql_config.py
M geowiki/process_data.py
M setup.py
3 files changed, 8 insertions(+), 7 deletions(-)
Approvals:
Milimetric: Verified; Looks good to me, approved
diff --git a/geowiki/mysql_config.py b/geowiki/mysql_config.py
index efdfd1a..51e8cb1 100644
--- a/geowiki/mysql_config.py
+++ b/geowiki/mysql_config.py
@@ -234,7 +234,7 @@
field_str = ',\n'.join(map(' '.join, field_types.items()))
command = 'CREATE TABLE IF NOT EXISTS %s (%s)' % (table_name,
field_str)
cursor.execute(command)
- cursor.connection.commit()
+ cursor.analytics_db.commit()
def get_dest_cursor(opts):
@@ -242,6 +242,7 @@
db = MySQLdb.connect(read_default_file=opts['dest_sql_cnf'],
db=opts['dest_db_name'])
cur = db.cursor(MySQLdb.cursors.Cursor)
#create_dest_tables(cur, opts)
+ cur.analytics_db = db
return cur
@@ -254,7 +255,7 @@
query_fmt = """REPLACE INTO %s (%s) VALUES (%s);""" % (table,
','.join(fields), dict_fmt)
#logging.debug(query_fmt)
cursor.executemany(query_fmt, active_editors_by_country)
- cursor.connection.commit()
+ cursor.analytics_db.commit()
def write_world_active_editors_mysql(world_active_editors, opts, cursor):
@@ -265,7 +266,7 @@
dict_fmt = ', '.join(map(lambda f: '%%(%s)s' % f, fields))
query_fmt = """REPLACE INTO %s (%s) VALUES (%s);""" % (table,
','.join(fields), dict_fmt)
cursor.executemany(query_fmt, world_active_editors)
- cursor.connection.commit()
+ cursor.analytics_db.commit()
def write_city_edit_fraction_mysql(city_edit_fractions, opts, cursor):
@@ -276,7 +277,7 @@
dict_fmt = ', '.join(map(lambda f: '%%(%s)s' % f, fields))
query_fmt = """REPLACE INTO %s (%s) VALUES (%s);""" % (table,
','.join(fields), dict_fmt)
cursor.executemany(query_fmt, city_edit_fractions)
- cursor.connection.commit()
+ cursor.analytics_db.commit()
def write_country_total_edits_mysql(country_totals, opts, cursor):
@@ -287,7 +288,7 @@
dict_fmt = ', '.join(map(lambda f: '%%(%s)s' % f, fields))
query_fmt = """REPLACE INTO %s (%s) VALUES (%s);""" % (table,
','.join(fields), dict_fmt)
cursor.executemany(query_fmt, country_totals)
- cursor.connection.commit()
+ cursor.analytics_db.commit()
def get_filepath(_type, project, opts):
diff --git a/geowiki/process_data.py b/geowiki/process_data.py
index 95239fd..4180cd3 100755
--- a/geowiki/process_data.py
+++ b/geowiki/process_data.py
@@ -78,7 +78,7 @@
query = mysql_config.construct_bot_query(wp_pr)
cur = mysql_config.get_analytics_cursor(wp_pr, opts, server_side=False)
cur.execute(query)
- cur.connection.close()
+ cur.close()
pr_bots = set(c[0] for c in cur)
diff --git a/setup.py b/setup.py
index abab0e5..4e750da 100644
--- a/setup.py
+++ b/setup.py
@@ -21,7 +21,7 @@
include_package_data=True,
install_requires=[
"argparse >=1.2.1",
- "MySQL-python >= 1.2.3",
+ "MySQL-python >= 1.3.7",
"geoip",
"gcat == 0.1.0",
],
--
To view, visit https://gerrit.wikimedia.org/r/365687
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I1799991823f3cc026551f9d86873f3614a276678
Gerrit-PatchSet: 1
Gerrit-Project: analytics/geowiki
Gerrit-Branch: master
Gerrit-Owner: Milimetric <[email protected]>
Gerrit-Reviewer: Milimetric <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits