当前位置: 首页>>代码示例>>Python>>正文


Python DatabaseManager.getInstance方法代码示例

本文整理汇总了Python中database.DatabaseManager.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Python DatabaseManager.getInstance方法的具体用法?Python DatabaseManager.getInstance怎么用?Python DatabaseManager.getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在database.DatabaseManager的用法示例。


在下文中一共展示了DatabaseManager.getInstance方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: createCharacter

# 需要导入模块: from database import DatabaseManager [as 别名]
# 或者: from database.DatabaseManager import getInstance [as 别名]
def createCharacter(account, name, model):
    
    if hasPlayer(name):
        raise CharacterAlreadyExists()
    try:
        ID = idFactory.createID()
        # these values are only for test puporse, must be tested and fixed
        # all players stats must be saved on DB
        if model == 1:
            spd = 2
            df = 2
            fc = 2
            hp = 300
        elif model == 2:
            spd = 1
            df = 2
            fc = 3
            hp = 350
        elif model == 3:
            spd = 3
            df = 1
            fc = 2
            hp = 250
        DB.getInstance().query("INSERT INTO Players (ID, account, name, speed, defense, `force`, maxHp, hp, model)" \
                               "Values (%s,%s,%s,%s,%s,%s,%s,%s,%s)",(ID,account,name,spd,df,fc,hp,hp,model))
    except Exception, e:
        print e
        return False
开发者ID:rafael146,项目名称:workufal,代码行数:30,代码来源:charManager.py

示例2: loadPlayer

# 需要导入模块: from database import DatabaseManager [as 别名]
# 或者: from database.DatabaseManager import getInstance [as 别名]
def loadPlayer(ID):
    rs = DB.getInstance().query("SELECT * FROM Players WHERE ID = %s",ID)
    if rs.next():
        player = Player()
        player.ID = rs.getInt('ID')
        player.name = rs.getString('name')
        player.speed = rs.getInt('speed')
        player.defense = rs.getInt('defense')
        player.force = rs.getInt('force')
        player.maxHp = rs.getInt('maxHp')
        player.hp = rs.getInt('hp')
        player.level = rs.getInt('level')
        player.x = rs.getInt('x')
        player.y = rs.getInt('y')
        player.exp = rs.getInt('exp')
        player.model = rs.getInt('model')
        player.heading = rs.getInt('heading')
        return player
开发者ID:rafael146,项目名称:workufal,代码行数:20,代码来源:charManager.py

示例3: load

# 需要导入模块: from database import DatabaseManager [as 别名]
# 或者: from database.DatabaseManager import getInstance [as 别名]
 def load(self):
     rs = DB.getInstance().query("SELECT ID FROM Players")
     while rs.next():
         self.allocate(rs.getInt('ID'))
     print "All IDs loaded"
开发者ID:rafael146,项目名称:workufal,代码行数:7,代码来源:idFactory.py

示例4: deletePlayer

# 需要导入模块: from database import DatabaseManager [as 别名]
# 或者: from database.DatabaseManager import getInstance [as 别名]
def deletePlayer(ID):
    try:
        DB.getInstance().query("DELETE FROM Players WHERE ID = %s",ID)
    except:
        return False
    return True
开发者ID:rafael146,项目名称:workufal,代码行数:8,代码来源:charManager.py

示例5: hasPlayer

# 需要导入模块: from database import DatabaseManager [as 别名]
# 或者: from database.DatabaseManager import getInstance [as 别名]
def hasPlayer(name):
    return not DB.getInstance().query("SELECT ID FROM Players WHERE name = %s",name).empty()
开发者ID:rafael146,项目名称:workufal,代码行数:4,代码来源:charManager.py

示例6: getPlayer

# 需要导入模块: from database import DatabaseManager [as 别名]
# 或者: from database.DatabaseManager import getInstance [as 别名]
def getPlayer(account):
    return DB.getInstance().query("SELECT * FROM Players WHERE account = %s",account)
开发者ID:rafael146,项目名称:workufal,代码行数:4,代码来源:charManager.py


注:本文中的database.DatabaseManager.getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。