For a school project, I\'m creating a game that has a score system, and I would like to create some sort of leaderboard. Once finished, the teachers will upload it to a shared s
The easiest is probably to just use mongodb or something (mongo DB is a nosql type database that allows you to save dictionary data easily...)
You can use the free account at https://mongolab.com (taht should give you plenty of space).
(You will need pymongo as well easy_install pymongo
).
then you can simply save records there
from pymongo import MongoClient
uri = "mongodb://test1:test1@ds051990.mongolab.com:51990/joran1"
my_db_cli = MongoClient(uri)
db = my_db_cli.joran1 #select the database ...
my_scores = db.scores #this will be created if it doesnt exist!
#add a new score
my_scores.insert({"user_name":"Leeeeroy Jenkins","score":124,"time":"11/24/2014 13:43:22"})
my_scores.insert({"user_name":"bob smith","score":88,"time":"11/24/2014 13:43:22"})
from pymongo import DESCENDING
#get a list of high scores (from best to worst)
print (list(my_scores.find().sort("score",DESCENDING)))
Those credentials will actually work if you want to test the system (keep in mind I added leeroy a few times).