MCPcopy Index your code
hub / github.com/bedroombuilds/python2rust / go

Function go

21_postgresql/python/pg_async.py:7–27  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5
6
7async def go():
8 async with aiopg.create_pool("host=localhost user=htd") as pool:
9 async with pool.acquire() as conn:
10 async with conn.cursor(cursor_factory=psycopg2.extras.DictCursor) as cur:
11 await cur.execute(helper.MOST_RECOVERED)
12 rows = await cur.fetchall()
13 print('most recoveries', dict(rows[0]))
14
15 await cur.execute("BEGIN") # conn.commit() not available
16 await cur.execute("DELETE FROM month_cases")
17 await cur.execute(helper.GROUP_BY_MONTH)
18 ret = []
19 async for row in cur:
20 ret.append(row)
21 for row in ret:
22 print(row)
23 await cur.execute(
24 '''INSERT INTO month_cases
25 (mon, new_cases, recovered)
26 VALUES (%s, %s, %s)''', row)
27 await cur.execute("COMMIT") # conn.commit() not available
28
29
30if __name__ == '__main__':

Callers 1

pg_async.pyFile · 0.85

Calls 1

printFunction · 0.50

Tested by

no test coverage detected