Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. Could not complete query "select uuid from wos_2017_1.combined_name where combined_name = 'xxxxxxx';"
  2. Traceback (most recent call last):
  3. File "update2017.py", line 1206, in runquery
  4. result = await con.fetch(query)
  5. File "/usr/lib/python3/dist-packages/asyncpg/connection.py", line 268, in fetch
  6. stmt = await self._get_statement(query, timeout)
  7. File "/usr/lib/python3/dist-packages/asyncpg/connection.py", line 212, in _get_statement
  8. state = await protocol.prepare(None, query, timeout)
  9. File "asyncpg/protocol/protocol.pyx", line 140, in prepare (asyncpg/protocol/protocol.c:55210)
  10. File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
  11. yield self # This tells Task to wait for completion.
  12. File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
  13. future.result()
  14. File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
  15. raise self._exception
  16. asyncpg.exceptions.DuplicatePreparedStatementError: prepared statement "stmt_7" already exists
  17.  
  18. $ grep -c INSERT /tmp/y.log
  19. 1006
  20. $ grep -c SELECT /tmp/y.log
  21. 1364
  22. $ grep -ci UPDATE /tmp/y.log
  23. 1044
  24. $ grep -ci delete /tmp/y.log
  25. 2548
  26.  
  27.  
  28.  
  29. import asyncio,asyncpg
  30.  
  31. async def make_pool():
  32. """Create asyncpg connection pool to database"""
  33.  
  34. pool = await asyncpg.create_pool(database='wos',
  35. host = 'localhost',
  36. user = 'xx',
  37. password='xxxxxx',
  38.  
  39.  
  40. port=5432,
  41. min_size=10,
  42. max_size=50)
  43.  
  44. return pool
  45.  
  46. async def get_con(pool):
  47. con = await pool.acquire()
  48. return con
  49.  
  50. async def runquery(query):
  51. con = await get_con(pool)
  52. try:
  53. if query.startswith('delete from') or query.startswith('insert'):
  54. result = await con.execute(query)
  55. else:
  56. result = await con.fetch(query)
  57. except:
  58. print('Could not complete query "{}"'.format(query))
  59. print(traceback.format_exc())
  60. result = None
  61. exit(1)
  62. finally:
  63. await pool.release(con)
  64. return result, success
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement