-
Notifications
You must be signed in to change notification settings - Fork 0
/
leaderboard.py
executable file
·52 lines (43 loc) · 1.48 KB
/
leaderboard.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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/python
import sys
sys.path.append("..")
import mysql.connector
import hive_submit as Submit
import openseed_setup as Settings
settings = Settings.get_settings()
def update_leaderboard(devID,appID,user,data,steem,postingkey):
openseed = mysql.connector.connect(
host = "localhost",
user = settings["dbuser"],
password = settings["dbpassword"],
database = "openseed"
)
scoresearch = openseed.cursor()
search = "SELECT * FROM `leaderboard` WHERE `devID` = '"+str(devID)+"' AND `appID` = '"+str(appID)+"' AND `username` ='"+str(user)+"' AND `data` = '"+str(data)+"'"
scoresearch.execute(search)
result = len(scoresearch.fetchall())
if result == 0:
sql = "INSERT INTO `leaderboard` (`devID`,`appID`,`username`,`data`) VALUES ('"+str(devID)+"','"+str(appID)+"','"+str(user)+"','"+str(data)+"')"
scoresearch.execute(sql)
openseed.commit()
Submit.leaderboard(devID,appID,user,data,steem,postingkey)
scoresearch.close()
openseed.close()
return "1"
def get_leaderboard(devID,appID):
openseed = mysql.connector.connect(
host = "localhost",
user = settings["dbuser"],
password = settings["dbpassword"],
database = "openseed"
)
scoresearch = openseed.cursor()
output = ""
search = "SELECT username,data FROM `leaderboard` WHERE `devID` = '"+str(devID)+"' AND `appID` = '"+str(appID)+"'"
scoresearch.execute(search)
result = scoresearch.fetchall()
for score in result:
output = str(score)+","+output
scoresearch.close()
openseed.close()
return str(output)