- if ignore_partitions:
- with connect(dsn) as conn:
- with conn.cursor() as cur:
- cur.execute('UPDATE country_name SET partition = 0')
- conn.commit()
+ params = []
+ for ccode, props in _COUNTRY_INFO.items():
+ if ccode is not None and props is not None:
+ if ignore_partitions:
+ partition = 0
+ else:
+ partition = props.get('partition')
+ if ',' in (props.get('languages', ',') or ','):
+ lang = None
+ else:
+ lang = props['languages']
+ params.append((ccode, partition, lang))
+
+ with connect(dsn) as conn:
+ with conn.cursor() as cur:
+ cur.execute_values(
+ """ UPDATE country_name
+ SET partition = part, country_default_language_code = lang
+ FROM (VALUES %s) AS v (cc, part, lang)
+ WHERE country_code = v.cc""", params)
+ conn.commit()