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


Python DBSession.query方法代码示例

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


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

示例1: get_by_key

# 需要导入模块: from model import DBSession [as 别名]
# 或者: from model.DBSession import query [as 别名]
 def get_by_key(cls, key):
     session = DBSession()
     if py_ver == 2:
         the_key = (key or b'').encode('utf-8')
     else:
         the_key = str(key or b'', 'utf-8')
     return session.query(cls).filter(cls.key==the_key).first()
开发者ID:fy0,项目名称:fpage,代码行数:9,代码来源:user.py

示例2: FlushofGamelist

# 需要导入模块: from model import DBSession [as 别名]
# 或者: from model.DBSession import query [as 别名]
 def FlushofGamelist(self):
     
     ''' No.1 clear table of gamelist '''
     localgamelist = DBSession.query(GameList).all()
     
     if len(localgamelist) != 0:
         for eachlist in range(len(localgamelist)):
             DBSession.delete(localgamelist[eachlist])
             
     DBSession.commit()
     
     ''' No.2 analyst Config and create conn '''
     self.getConfig = readFromConfigFile().get_config_zonelist('/WebserviceInterface/ServiceConfig/setting.ini')
     
     for eachTuple in range(len(self.getConfig['Zonelist'])):
         if self.getConfig['Zonelist'][eachTuple][0] == 'username':
             self.change['username'] = self.getConfig['Zonelist'][eachTuple][1]
         elif self.getConfig['Zonelist'][eachTuple][0] == 'password':
             self.change['password'] = self.getConfig['Zonelist'][eachTuple][1]
         elif self.getConfig['Zonelist'][eachTuple][0] == 'ipaddress':
             self.change['ipaddress'] = self.getConfig['Zonelist'][eachTuple][1]
         elif self.getConfig['Zonelist'][eachTuple][0] == 'port':
             self.change['port'] = int(self.getConfig['Zonelist'][eachTuple][1])
         elif self.getConfig['Zonelist'][eachTuple][0] == 'dbname':
             self.change['dbname'] = self.getConfig['Zonelist'][eachTuple][1]
         elif self.getConfig['Zonelist'][eachTuple][0] == 'tablename':
             self.change['tablename'] = self.getConfig['Zonelist'][eachTuple][1]
     
     (conn, cursor) = Connect().create(self.change)
     
     sql = 'select * from %s' % self.change['tablename']
     cursor.execute(sql)
     result=cursor.fetchall()
     for i in result:
         print i
开发者ID:qbaoma,项目名称:web,代码行数:37,代码来源:flushtables.py

示例3: auth

# 需要导入模块: from model import DBSession [as 别名]
# 或者: from model.DBSession import query [as 别名]
    def auth(cls, username, password):
        session = DBSession()
        u = session.query(cls).filter(cls.username==username).first()
        if not u:
            return False
        password_md5 = md5(password.encode('utf-8')).hexdigest()
        password_final = md5((password_md5 + u.salt).encode('utf-8')).hexdigest()

        if u.password == password_final:
            return u
开发者ID:wuchangqi,项目名称:fpage,代码行数:12,代码来源:user.py

示例4: searchObject

# 需要导入模块: from model import DBSession [as 别名]
# 或者: from model.DBSession import query [as 别名]
    def searchObject(self, machineroom, requestobject):
        
        try:
            allsearch = DBSession.query(ASSET).filter(and_(ASSET.partNum.like("%"+requestobject+"%"), ASSET.machineRoom.like("%"+machineroom+"%"), ASSET.useNow == 'Y')).all()

            for eachAsset in range(len(allsearch)):
                self.assetBack[allsearch[eachAsset].id] = dict(confNum=allsearch[eachAsset].confNum, serialNum=allsearch[eachAsset].serialNum, hostname=allsearch[eachAsset].hostname, companyIp=allsearch[eachAsset].companyIp, outIp=allsearch[eachAsset].outIp, storeIp=allsearch[eachAsset].storeIp, zcbm=allsearch[eachAsset].zcbm)
             
        except Exception, e:
            return dict(Status='false', Return=e)
开发者ID:qbaoma,项目名称:web,代码行数:12,代码来源:localAsset.py

示例5: getDatabase

# 需要导入模块: from model import DBSession [as 别名]
# 或者: from model.DBSession import query [as 别名]
 def getDatabase(self):
 
     searchLocal = DBSession.query(ASSET).all()
     if len(searchLocal) > 100:
         print "local table.asset has data. needn't."
     else:
         self.flush(self.cursor)
         
     self.cursor.close()
     self.OracleConn.close()
开发者ID:qbaoma,项目名称:web,代码行数:12,代码来源:orcl.py

示例6: analyNode

# 需要导入模块: from model import DBSession [as 别名]
# 或者: from model.DBSession import query [as 别名]
    def analyNode(self, AgentZone):

        try:
            getNodeInform = DBSession.query(NodeList).filter_by(NodeZone = AgentZone).all()
            if getNodeInform:
                for eachNodeInform in range(len(getNodeInform)):
                    self.Nodeinform[getNodeInform[eachNodeInform].NodeID]=dict(NodeType=getNodeInform[eachNodeInform].NodeType, NodeZone=getNodeInform[eachNodeInform].NodeZone, NodeName=getNodeInform[eachNodeInform].NodeName, IP=getNodeInform[eachNodeInform].IP, Port=getNodeInform[eachNodeInform].Port)
            else:
                msg = 'MySQLdb : select from table.nodelist error.'
                return msg
      
        except Exception, e:
            return e
开发者ID:qbaoma,项目名称:web,代码行数:15,代码来源:getNode.py

示例7: Recovery

# 需要导入模块: from model import DBSession [as 别名]
# 或者: from model.DBSession import query [as 别名]
    def Recovery(self):
        
        localAsset = DBSession.query(ASSET).all()

        if len(localAsset) > 100:
            for eachAsset in range(len(localAsset)):
                DBSession.delete(localAsset[eachAsset])
            DBSession.commit()
            
            self.flush(self.cursor)
        else:
            self.flush(self.cursor)
            
        self.cursor.close() 
        self.OracleConn.close()
开发者ID:qbaoma,项目名称:web,代码行数:17,代码来源:orcl.py

示例8: flushAgent

# 需要导入模块: from model import DBSession [as 别名]
# 或者: from model.DBSession import query [as 别名]
    def flushAgent(self,  machineroomSimple, Agent='Agent'):
        
        try:
            getSearchAgent = DBSession.query(Translate).filter_by(simple = Agent).first()
            AgentSimple = getSearchAgent.detail
            
            getSearchMachineroom = DBSession.query(Translate).filter_by(simple = machineroomSimple).first()
            MrDetail = getSearchMachineroom.detail
            
            getAgentList = AssetInformation().searchObject(MrDetail, AgentSimple)

            print "######## LEN ", len(getAgentList['Return'])

            for key,value in getAgentList['Return'].items():
                AgentID = key
                AgentZone = machineroomSimple
                AgentName = value['hostname']
                IP = self.iprule(key, machineroomSimple, value['companyIp'], value['outIp'], value['storeIp'])
                Port = 'NULL'
                IsUse = 1
            
            
        except Exception, e:
            return e
开发者ID:qbaoma,项目名称:web,代码行数:26,代码来源:allist.py

示例9: show_article

# 需要导入模块: from model import DBSession [as 别名]
# 或者: from model.DBSession import query [as 别名]
def show_article(context, request):
    article = {}
    db_result = DBSession.query(Article).filter(
        Article.id == context.article
    ).first()

    if not db_result:
        raise HTTPNotFound(
            "Article could not be found"
        )

    article['id'] = db_result.id
    article['title'] = db_result.title
    article['body'] = db_result.body

    return {
        'article': article,
        'back_url': route_url('article_list', request)
    }
开发者ID:bosim,项目名称:pyramid-talk,代码行数:21,代码来源:views.py

示例10: article_list

# 需要导入模块: from model import DBSession [as 别名]
# 或者: from model.DBSession import query [as 别名]
def article_list(request):
    results = []
    db_results = DBSession.query(Article).all()

    for db_result in db_results:
        results.append({
            'id': db_result.id,
            'url': route_url(
                'show_article',
                request,
                article=str(db_result.id)
            ),
            'title': db_result.title
        })

    return {
        'articles': results,
        'add_article': route_url('add_article', request)
    }
开发者ID:bosim,项目名称:pyramid-talk,代码行数:21,代码来源:views.py

示例11: FromConfNum

# 需要导入模块: from model import DBSession [as 别名]
# 或者: from model.DBSession import query [as 别名]
 def FromConfNum(self, confNum):
     
     Attitude = ""
     ServerInform = {}
     Internet = {}
     Device = {}
     
     try:
         self.allLineofConfnum = DBSession.query(ASSET).filter_by(confNum = confNum).first()
         print self.allLineofConfnum
         
         if self.allLineofConfnum:
             
             # All information collect
             Attitude = self.allLineofConfnum.useNow
                   
             Device['confNum'] = self.allLineofConfnum.confNum
             Device['partNum'] = self.allLineofConfnum.partNum
             Device['serialNum'] = self.allLineofConfnum.serialNum
             Device['zcbm'] = self.allLineofConfnum.zcbm
             Device['machineRoom'] = self.allLineofConfnum.machineRoom
             
             ServerInform['useProperty'] = self.allLineofConfnum.useProperty
             ServerInform['conProject'] = self.allLineofConfnum.conProject
             ServerInform['username'] = self.allLineofConfnum.username
             ServerInform['userId'] = self.allLineofConfnum.userId
             ServerInform['usage'] = self.allLineofConfnum.usage
             
             Internet['hostname'] = self.allLineofConfnum.hostname
             Internet['companyIp'] = self.allLineofConfnum.companyIp
             Internet['outIp'] = self.allLineofConfnum.outIp
             Internet['storeIp'] = self.allLineofConfnum.storeIp
             
             return dict(State=Attitude, Device=Device, ServerInform=ServerInform, Internet=Internet)
             
         else:
             msg = 'MySQLdb : could not found any confNum.'
             return msg
     
     except Exception, e:
         msg = e
         return msg
开发者ID:qbaoma,项目名称:web,代码行数:44,代码来源:localAsset.py

示例12: getFlushoftable

# 需要导入模块: from model import DBSession [as 别名]
# 或者: from model.DBSession import query [as 别名]
    def getFlushoftable(self, signal='ALL'):
        
        # No.1 clear table of gamename
        localGameName = DBSession.query(Gameinform).all()
        
        if len(localGameName) != 0:
            for eachGamename in range(len(localGameName)):
                DBSession.delete(localGameName[eachGamename])
        
        DBSession.commit()
       
        # No.2 get each Game information & fill in table
       
        self.flush = Urlex().getInformationMultiple(signal)
    
        for key,value in self.flush.items():
            if key != 'NULL':
                DBSession.add(Gameinform(self.count, key, value['ipaddress'], value['port'], value['dbname']))
                self.count += 1

        DBSession.commit()
开发者ID:qbaoma,项目名称:web,代码行数:23,代码来源:flushtables.py

示例13: transportData

# 需要导入模块: from model import DBSession [as 别名]
# 或者: from model.DBSession import query [as 别名]
 def transportData(self, machineroomSimple, data):
     
     allAgent = DBSession.query(AgentList).all()
     allSwitch = DBSession.query(SwitchList).all()
     
     self.flushAgent(machineroomSimple)
开发者ID:qbaoma,项目名称:web,代码行数:8,代码来源:allist.py

示例14: count

# 需要导入模块: from model import DBSession [as 别名]
# 或者: from model.DBSession import query [as 别名]
 def count(cls):
     session = DBSession()
     return session.query(cls).filter(cls.state>0).count()
开发者ID:fy0,项目名称:fpage,代码行数:5,代码来源:user.py

示例15: get_by_username

# 需要导入模块: from model import DBSession [as 别名]
# 或者: from model.DBSession import query [as 别名]
 def get_by_username(cls, username):
     username = username.lower()
     session = DBSession()
     return session.query(cls).filter(cls.username==username).first()
开发者ID:fy0,项目名称:fpage,代码行数:6,代码来源:user.py


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