Skip to content

Instantly share code, notes, and snippets.

class Rank(db.Model):
__tablename__ = 'rank'
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
player = db.Column(db.Integer, db.ForeignKey(Player), nullable=False, index=True)
region = db.Column(db.String(3), nullable=False, index=True)
mode = db.Column(db.String(5), nullable=False, index=True)
timestamp = db.Column(db.Timestamp, nullable=False, default=func.now())
score_rank = db.Column(db.Integer, nullable=False)
kill_rank = db.Column(db.Integer, nullable=False)
win_rank = db.Column(db.Integer, nullable=False)
def request_(req_url, sleep_time=1):
succeeded = False
while not succeeded:
try:
print("Requesting: %s" % req_url)
request = Request(req_url)
request.add_header('User-Agent',
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36')
response = urlopen(request)
out = response.read().decode(