blob: 315c82c81641e8aa2d989183de03067f1ad1eefc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
import asyncio
import asyncpg
import datetime
async def dbconn():
conn = await asyncpg.connect(user='serenitas_user', password='Serenitas1',
database='serenitasdb', host='debian')
return conn
async def get_singlenames_quotes_async(indexname, date):
con = await dbconn()
stmt = await con.prepare('SELECT * FROM curve_quotes($1, $2)')
async with con.transaction():
# Postgres requires non-scrollable cursors to be created
# and used in a transaction.
async for record in stmt.cursor(indexname, date):
print(record)
await con.close()
loop = asyncio.get_event_loop()
loop.run_until_complete(get_singlenames_quotes_async("ig27", datetime.date.today()))
|