Created
January 25, 2017 11:04
-
-
Save rudibroekhuizen/7f1de5f20e30c5594f6d3221d7d1c2ae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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