From 6ab2b7bd9cf28833bdd8017fdfaef3d4906b71f2 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Tue, 25 Feb 2020 15:27:37 -0500 Subject: [PATCH] sqlExport: Add some informational prints --- sqlExport.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/sqlExport.py b/sqlExport.py index 1f58463..6f16ba2 100644 --- a/sqlExport.py +++ b/sqlExport.py @@ -64,6 +64,7 @@ def createDefinitionsFromTableMap(tableMap): for k, v in tableMap.items()]) try: + print("Creating tables...") c.execute('CREATE TABLE IF NOT EXISTS members (' + createDefinitionsFromTableMap(tableMapping['members']) + ') WITH SYSTEM VERSIONING;') @@ -84,6 +85,13 @@ try: FOREIGN KEY(label_id) REFERENCES labels(label_id) ) WITH SYSTEM VERSIONING;""") + print("Updating labels") + c.executemany("""INSERT INTO labels (label, label_id) VALUES (%s, %s) + ON DUPLICATE KEY UPDATE + label=VALUES(label), label_id=VALUES(label_id);""", + membershipworks._parse_flags()['labels'].items()) + + print("Getting/Updating members...") members = membershipworks.get_all_members() for m in members: # replace flags by booleans @@ -96,18 +104,15 @@ try: if field.get('typ') == 8 and field['lbl'] in m: # check box m[field['lbl']] = True if m[field['lbl']] == 'Y' else False - c.executemany("""INSERT INTO labels (label, label_id) VALUES (%s, %s) - ON DUPLICATE KEY UPDATE - label=VALUES(label), label_id=VALUES(label_id);""", - membershipworks._parse_flags()['labels'].items()) - insertFromTableMap('members', members, tableMapping['members']) insertLabels(members) + print("Getting/Updating transactions...") transactions = membershipworks.get_transactions(datetime(2020, 1, 1), datetime.now()) insertFromTableMap('transactions', transactions, tableMapping['transactions']) + print("Committing changes...") conn.commit() except Exception as e: