-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusers.py
25 lines (21 loc) · 712 Bytes
/
users.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
import asyncio
import asyncpg
import datetime
async def main():
# Establish a connection to an existing database named "test"
# as a "postgres" user.
try:
conn = await asyncpg.connect('postgresql://admin:secret@idp-db:5432/keycloak?sslmode=disable')
records = await conn.fetch('''
SELECT * FROM keycloak_group;
''')
values = [dict(record) for record in records]
print(values)
print('Connected!')
except asyncpg.PostgresError:
print('error occurred', e)
# Execute a statement to create a new table.
# Close the connection.
#await conn.close()
hola = asyncio.get_event_loop().run_until_complete(main())
print(hola)