コード例 #1
0
def getPlayer(name):
    conn = config.getConnection()
    cur = conn.cursor()
    cur.execute("SELECT * FROM players where player_name = %s;", (name, ))
    name,rating,wins,loses = cur.fetchone()
    cur.close()
    conn.close()
    return LeagueManager.Player(name=name, rating=rating, wins=wins, loses=loses)
コード例 #2
0
ファイル: flask_tests.py プロジェクト: stevenup7/flsk1
 def setUp(self):
     self.app = app.app.test_client()
     db = getConnection()
     newUser = {
         "username": "******",
         "levels": ["SUPERUSER"],
         "passwordhashed": hashPass('test')        
         }
     self.entry = createMongoDocument(db.users, newUser)  
コード例 #3
0
    def __init__(self, lotName, totalSpots):
        '''
        When initializing an instance of ParkingLot,
        connect to MongoDB
        '''
        self.lotName = lotName.replace(' ', '').lower()
        self.parkingDataCollectionName = self.lotName

        self.totalSpots = totalSpots

        # Connect to mongodb using connection string
        self.connection = pymongo.MongoClient(getConnection())

        # Create/Search for a database called test
        self.database = self.connection['test']
        self.collection = self.database[self.lotName]
コード例 #4
0
def updateRating(name,rating):
    conn = config.getConnection()
    cur = conn.cursor()
    cur.execute("update players set rating=%s where player_name == %s;", (rating,name))
    cur.close()
    conn.close()
コード例 #5
0
def addLoss(name):
    conn = config.getConnection()
    cur = conn.cursor()
    cur.execute("update players set loses=loses+1 where player_name == %s;", (name,))
    cur.close()
    conn.close()
コード例 #6
0
ファイル: flask_tests.py プロジェクト: stevenup7/flsk1
 def tearDown(self):
 	db = getConnection()
     deleteMongoDocument(db.users, self.entry['id'])