[git fast commit] 29. Jan 2019 - 19:00:22

This commit is contained in:
Yannik Schmidt
2019-01-29 19:00:22 +01:00
parent d6480e2411
commit 62fa05962c
4 changed files with 37 additions and 18 deletions

23
PSQL.py Normal file
View File

@@ -0,0 +1,23 @@
import psycopg2
def save(dname,user,host,password,data):
conn = psycopg2.connect("dbname={} user={} host={} password={}".format(dname,user,host,password))
cur = conn.cursor()
tup = ()
if type(data) == dict:
for player in data:
d = dict()
d.update("steamid",p.steamid)
d.update("name",p.name)
d.update("wins",p.wins)
d.update("games",p.games)
d.update("mu",p.rating.mu)
d.update("sigma",p.rating.sigma)
tup += (d,)
cur.executemany("""INSERT INTO ratings(steamid,name,wins,games,mu,sigma) \
VALUES (%(steamid)s,%(name)s,%(wins)s,%(games)s,%(mu)s,%(sigma)s)""",d)
elif isinstance(data,Event):
cur.exceutemany("""INSERT INTO events(etype,timestamp,line) \
VALUES (%(etype)s,%(timestamp)s,%(line)s)""",data)
def query_buddies(steamid):
return []