Skip to content

Instantly share code, notes, and snippets.

@rudibroekhuizen
Created January 25, 2017 11:04
Show Gist options
  • Save rudibroekhuizen/7f1de5f20e30c5594f6d3221d7d1c2ae to your computer and use it in GitHub Desktop.
Save rudibroekhuizen/7f1de5f20e30c5594f6d3221d7d1c2ae to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import asyncio
import asyncpg
#DB_CONFIG = {
# 'host': 'localhost',
# 'user': 'drupal_user',
# 'password': 'password',
# 'port': 5432,
# 'database': 'drupaldb'
#}
async def run():
conn = await asyncpg.connect(user='drupal_user', password='password',
database='drupaldb', host='127.0.0.1')
values = await conn.fetch('''COPY (select row_to_json(pg_stat_all_tables) from pg_stat_all_tables) TO '/tmp/out.json';''')
await conn.close()
for value in values:
print(value)
loop = asyncio.get_event_loop()
loop.run_until_complete(run())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment