diff options
| author | Kapil Viren Ahuja <kvahuja@users.noreply.github.com> | 2017-02-16 22:18:04 +0530 |
|---|---|---|
| committer | schneefux <schneefux+github@schneefux.xyz> | 2017-02-16 17:48:04 +0100 |
| commit | 07f17264500c388cb039eb33cdd89bc4f54d9505 (patch) | |
| tree | 3820fe6620ab170242fca870311798d5246c4d3d /api.py | |
| parent | 5a932151539247fef874c9bcb8e49b8483c529cd (diff) | |
| download | shrinker-07f17264500c388cb039eb33cdd89bc4f54d9505.tar.gz shrinker-07f17264500c388cb039eb33cdd89bc4f54d9505.zip | |
1. using the right table names in SQL. 2. also put in some exception handling which spits out the error and moves on instead of exiting (#11)
* 1. using the right table names in SQL. 2. also put in some exception handling which spits out the error and moves on instead of exiting
* ID in participant table is participant ID. we need a mapping for player ID in Web to get a player's matches.
Diffstat (limited to 'api.py')
| -rw-r--r-- | api.py | 17 |
1 files changed, 13 insertions, 4 deletions
@@ -53,12 +53,17 @@ class Processor(object): async with self._srcpool.acquire() as srccon: async with self._destpool.acquire() as destcon: for table, query in self._queries.items(): + logging.info("running query for '%s'", table) stop_after -= 1 # TODO for debugging, don't process whole table - logging.info("processing table %s", table) async with srccon.transaction(): async with destcon.transaction(): - async for rec in srccon.cursor(query): - await self.into(destcon, rec, table) + rec_o = "" + try: + async for rec in srccon.cursor(query): + rec_o = rec + await self.into(destcon, rec, table) + except: + logging.error("rec: %s", rec_o) async def into(self, conn, data, table): """Insert a named tuple into a table.""" @@ -67,7 +72,11 @@ class Processor(object): placeholders = ["${}".format(i) for i, _ in enumerate(values, 1)] query = "INSERT INTO {} (\"{}\") VALUES ({})".format( table, "\", \"".join(keys), ", ".join(placeholders)) - await conn.execute(query, (*data)) + try: + await conn.execute(query, (*data)) + except: + logging.error("Query: '%s'", query) + logging.error("Data: '%s'", data) async def main(): |
