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


Python DBSession.delete方法代码示例

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


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

示例1: FlushofGamelist

# 需要导入模块: from model import DBSession [as 别名]
# 或者: from model.DBSession import delete [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

示例2: Recovery

# 需要导入模块: from model import DBSession [as 别名]
# 或者: from model.DBSession import delete [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

示例3: getFlushoftable

# 需要导入模块: from model import DBSession [as 别名]
# 或者: from model.DBSession import delete [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

示例4: DetailforEachOid

# 需要导入模块: from model import DBSession [as 别名]
# 或者: from model.DBSession import delete [as 别名]

#.........这里部分代码省略.........
                        tmpEthInfo[tmpethname] = dict(status=tmpStatus, ip=tmpip, mask=tmpmask)

            if tmpZCBM == '':
                return dict(Status='False', msg='Input Server has not ZCBM.')

            ''' get eth detail '''
            tmpEthDict = {}
            for key,value in tmpEthInfo.items():
                if key == 'eth0':
                    getSearchofeth = DBSession.query(Ethdetail).filter(Ethdetail.ip == value['ip'], Ethdetail.mask == value['mask']).first()
                    if getSearchofeth:
                        tmpEthDict['eth0'] = getSearchofeth.eid
                    else:
                        getethcount = DBSession.query(Ethdetail).count()
                        getethcount = (getethcount + 1)
                        DBSession.add(Ethdetail(getethcount,value['status'],value['ip'],value['mask'],'eth0'))
                        tmpEthDict['eth0'] = getethcount
                elif key == 'eth1':
                    getSearchofethone = DBSession.query(Ethdetail).filter(Ethdetail.ip == value['ip'], Ethdetail.mask == value['mask']).first()
                    if getSearchofethone:
                        tmpEthDict['eth1'] = getSearchofethone.eid
                    else:
                        getethcountone = DBSession.query(Ethdetail).count()
                        getethcountone = (getethcountone + 1)
                        DBSession.add(Ethdetail(getethcountone,value['status'],value['ip'],value['mask'],'eth1'))
                        tmpEthDict['eth1'] = getethcountone

            ''' Step 2. check server information exist. '''
            getSearchofHardware = DBSession.query(AssetForAgent).filter(AssetForAgent.ZCBM == tmpZCBM).first()
            if getSearchofHardware:
                try:
                    if int(getSearchofHardware.Timestamp) < message['SendTime']:

                        DBSession.delete(getSearchofHardware)
                        DBSession.commit()
                        
                        tmpeth0 = ""
                        tmpeth1 = ""
                        
                        for key,value in tmpEthDict.items():
                            if key == 'eth0':
                                tmpeth0 = value
                            elif key == 'eth1':
                                tmpeth1 = value
                        getCountofeth = DBSession.query(EthInfo).count()
                        getCountofeth = (getCountofeth + 1)
                        DBSession.add(EthInfo(getCountofeth,tmpeth0,tmpeth1,'None','None'))
                        
                        DBSession.add(AssetForAgent(tmpProjectName, tmpProjectFunc, tmpKernel, tmpCpuCoreNum, tmpSerialNum, tmpZCBM, tmpMemory, tmpCpuType, tmpModel, tmpHostName, tmpOS, tmpManufacturer, message['SendTime']))
                        DBSession.commit()
                        
                        getTmpid = DBSession.query(AssetForAgent).filter_by(ZCBM = tmpZCBM).first()
                        if getTmpid:
                            Tmpid = getTmpid.Hid
                        else:
                            DBSession.rollback()
                            return dict(Status='False', msg='flush assetforagent Error.')
                        
                        getCountofrelation = DBSession.query(AssetidtoEid).count()
                        getCountofrelation = int(getCountofrelation + 1)
                        DBSession.add(AssetidtoEid(getCountofrelation, Tmpid, getCountofeth))
                        
                        DBSession.commit()
                        return dict(Status='Success')
                        
                    else:
开发者ID:qbaoma,项目名称:web,代码行数:70,代码来源:oidDetail.py


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