-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexp.py
36 lines (27 loc) · 915 Bytes
/
exp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import asyncio
from back.db_conn_async import connection
async def get_tables():
conn = await connection()
tables = []
async with conn.transaction():
async for record in conn.cursor("select table_name from information_schema.tables where table_schema = 'public'"):
tables.append(record[0])
return tables
async def get_names_list(tablename):
conn = await connection()
q = 'select name from ' + tablename
file = tablename + '.txt'
t = []
async with conn.transaction():
async for record in conn.cursor(q):
if record[0] not in t:
t.append(record[0])
with open(file, mode='a+') as f:
for i in t:
f.write(i)
f.write('\n')
f.close()
async def run():
for i in await get_tables():
await get_names_list(i)
asyncio.get_event_loop().run_until_complete(run())