blob: 168620485eeeb6ba40125d03daa172f71259ba90 (
plain)
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
|
#!/usr/bin/python
import asyncio
import database
import crawler
import datetime
async def main():
db = database.Database()
await db.connect("postgres://vgstats@localhost/vgstats")
api = crawler.Crawler()
try:
await db.meta("last_match_update")
except KeyError:
await db.meta("last_match_update",
datetime.datetime(1, 1, 1).isoformat())
matches = await api.matches_since(
await db.meta("last_match_update"))
await db.upsert("na", matches, True)
print(await db.select("SELECT data->'attributes'->>'name' as name FROM player WHERE CAST(data->'attributes'->'stats'->>'winStreak' AS integer) > 3"))
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.close()
|