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


Python Database.close方法代码示例

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


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

示例1: exportHouseholds

# 需要导入模块: from model.database import Database [as 别名]
# 或者: from model.database.Database import close [as 别名]
 def exportHouseholds(self, project,  filename):
     database = Database()
     database.open()
     
     query = '''SELECT hhid, householdname, dateofcollection FROM households
                   WHERE pid=%s''' % project.pid
                   
     households = database.execSelectQuery( query )
     
     database.close()
     
     ihmFile = open(filename, 'a')
     for household in households:
         householdline = '''INSERT INTO households(pid,hhid,householdname,dateofcollection) 
                 VALUES({pid},%s, '%s', '%s')<endl>\n''' % (household[0], household[1], household[2])
         ihmFile.write(householdline)
     ihmFile.close()
     
     self.exportHouseholdCharacteristics(project, filename)
     self.exportHouseholdAssets(project, filename)
     self.exportHouseholdExpenditure(project, filename)
     self.exportHouseholdCropIncome(project, filename)
     self.exportHouseholdLivestockIncome(project, filename)
     self.exportHouseholdWildfoodsIncome(project, filename)
     self.exportHouseholdEmploymentIncome(project, filename)
     self.exportHouseholdTransfersIncome(project, filename)
     self.exportHouseholdMembers(project, filename)
开发者ID:r4vi,项目名称:open-ihm,代码行数:29,代码来源:openihmexportmanager1.py

示例2: getProjectsMatching

# 需要导入模块: from model.database import Database [as 别名]
# 或者: from model.database.Database import close [as 别名]
 def getProjectsMatching(self,  pid="",  ptitle=""):
     SQLcondition 	= ""
     if ( pid != "" ):
         SQLcondition = " WHERE pid=%s" % pid
     
     if ( ptitle != "" ):
         if ( SQLcondition == "" ):
             SQLcondition = " WHERE projectname LIKE '%" + "%s" % ( ptitle ) + "%'" 
         else:
             SQLcondition = SQLcondition + " OR projectname LIKE '%" + "%s" % ( ptitle ) + "%'" 
             
     query = ''' SELECT pid FROM projects%s''' % ( SQLcondition )
     
     database = Database()
     database.open()
     rows = database.execSelectQuery(  query )
     database.close()
     
     projects = []
     for row in rows:
         pid = row[0]
         project = Project(pid)
         projects.append( project )
     
     return projects
开发者ID:r4vi,项目名称:open-ihm,代码行数:27,代码来源:controller.py

示例3: __init__

# 需要导入模块: from model.database import Database [as 别名]
# 或者: from model.database.Database import close [as 别名]
class GlobalHouseholdCharacteristicsManager:
    def __init__(self):
        self.database = Database()

    def getGlobalHouseholdCharacteristic(self, charid=0, charname=""):
        char = GlobalHouseholdCharacteristic(charid, charname)
        return char

    def addGlobalHouseholdCharacteristic(self, charname, datatype):
        char = GlobalHouseholdCharacteristic(0, charname, datatype)
        return char

    def editGlobalHouseholdCharacteristic(self, charid, charname, datatype):
        char = GlobalHouseholdCharacteristic(charid)
        char.setData(charname, datatype)

    def delGlobalHouseholdCharacteristic(self, charid="", charname=""):
        query = "DELETE FROM globalhouseholdcharacteristics WHERE id=%i OR characteristic='%s' " % (charid, charname)
        self.database.open()
        self.database.execUpdateQuery(query)
        self.database.close()

    def getGlobalHouseholdCharacteristics(self):
        query = "SELECT id FROM globalhouseholdcharacteristics"
        self.database.open()
        rows = self.database.execSelectQuery(query)
        self.database.close()
        chars = []

        for row in rows:
            charid = row[0]
            char = GlobalHouseholdCharacteristic(charid)
            chars.append(char)

        return chars
开发者ID:r4vi,项目名称:open-ihm,代码行数:37,代码来源:globalhouseholdcharacteristicsmanager.py

示例4: logIhmTransfer

# 需要导入模块: from model.database import Database [as 别名]
# 或者: from model.database.Database import close [as 别名]
 def logIhmTransfer(self, pid, pid_access, projectname, startdate, currency ):
     query = '''INSERT INTO transferlog(pid,pid_access,projectname,datecollected,currency) 
                  VALUES(%s,%s,'%s','%s','%s')''' % (pid, pid_access, projectname, startdate, currency)
                      
     database = Database()
     database.open()
     database.execUpdateQuery( query )
     database.close()
开发者ID:r4vi,项目名称:open-ihm,代码行数:10,代码来源:openihmimportmanager1.py

示例5: test_execDefinitionQuery

# 需要导入模块: from model.database import Database [as 别名]
# 或者: from model.database.Database import close [as 别名]
 def test_execDefinitionQuery(self):
     self.helper.setup_clean_db()
     database = Database()
     database.open()
     database.execDefinitionQuery('create table simples (test int)')
     database.close()
     # and just to prove it's there to put something into.
     database.open()
     database.execUpdateQuery('insert into simples values (3)')
     database.close()
开发者ID:snim2mirror,项目名称:openihm,代码行数:12,代码来源:test_model_database.py

示例6: getGlobalPersonCharacteristics

# 需要导入模块: from model.database import Database [as 别名]
# 或者: from model.database.Database import close [as 别名]
 def getGlobalPersonCharacteristics(self):        
    query = "SELECT id FROM globalpersonalcharacteristics"
    database = Database()
    atabase.open()
    rows = database.execSelectQuery( query )
    database.close()
    chars = []
    
    for row in rows:
        charid = row[0]
        char = GlobalPersonCharacteristic(charid)
        chars.append( char )
        
    return chars
开发者ID:r4vi,项目名称:open-ihm,代码行数:16,代码来源:globalpersoncharacteristicsmanager.py

示例7: getProjects

# 需要导入模块: from model.database import Database [as 别名]
# 或者: from model.database.Database import close [as 别名]
 def getProjects(self):       
     query = "SELECT pid FROM projects"
     database = Database()
     database.open()
     rows = database.execSelectQuery( query )
     database.close()
     projects = []
     
     for row in rows:
         pid = row[0]
         project = Project(pid)
         projects.append( project )
         
     return projects
开发者ID:r4vi,项目名称:open-ihm,代码行数:16,代码来源:controller.py

示例8: test_execUpdateQuery

# 需要导入模块: from model.database import Database [as 别名]
# 或者: from model.database.Database import close [as 别名]
 def test_execUpdateQuery(self):
     self.helper.setup_clean_db()
     database = Database()
     database.open()
     database.execUpdateQuery("""
         insert into projects
           (projectname, startdate, enddate, description, currency)
         values
           ('test', '2012-06-04', '2013-07-03', 'a simple test', 'GBP')""")
     query = 'select * from projects'
     self.assertEqual([(2, u'test', datetime.date(2012, 6, 4),
                     datetime.date(2013, 7, 3), u'a simple test', u'GBP')],
                     database.execSelectQuery(query))
     database.close()
开发者ID:snim2mirror,项目名称:openihm,代码行数:16,代码来源:test_model_database.py

示例9: exportProjectIncomeSources

# 需要导入模块: from model.database import Database [as 别名]
# 或者: from model.database.Database import close [as 别名]
 def exportProjectIncomeSources(self, project, filename):
     database = Database()
     database.open()
     
     query = '''SELECT incomesource, incometype FROM projectincomesources
                   WHERE pid=%s''' % project.pid
                   
     incomes = database.execSelectQuery( query )
     
     database.close()
     ihmFile = open(filename, 'a')
     for inc in incomes:
         incomeline = '''INSERT INTO projectincomesources(pid,incomesource,incometype) 
         VALUES({pid},'%s','%s')<endl>\n''' % (inc[0], inc[1])
         ihmFile.write(incomeline)
     ihmFile.close()
开发者ID:r4vi,项目名称:open-ihm,代码行数:18,代码来源:openihmexportmanager1.py

示例10: delCorrespondingIhmProject

# 需要导入模块: from model.database import Database [as 别名]
# 或者: from model.database.Database import close [as 别名]
 def delCorrespondingIhmProject(self, projectname, startdate,  currency):
     ''' Delete if the project was transfered before '''
     
     query = '''SELECT projects.pid FROM projects, transferlog WHERE projects.pid=transferlog.pid  
                  AND transferlog.projectname='%s' AND transferlog.datecollected='%s' 
                  AND transferlog.currency='%s' ''' % (projectname,  startdate, currency)
                  
     db = Database()
     db.open() 
     records = db.execSelectQuery( query )
     for record in records:
         pid = record[0]
         query = '''DELETE FROM projects WHERE pid=%s''' % pid
         db.execUpdateQuery( query )
    
     db.close()
开发者ID:r4vi,项目名称:open-ihm,代码行数:18,代码来源:openihmimportmanager1.py

示例11: exportHouseholdAssets

# 需要导入模块: from model.database import Database [as 别名]
# 或者: from model.database.Database import close [as 别名]
 def exportHouseholdAssets(self, project, filename):
     database = Database()
     database.open()
     
     query = '''SELECT hhid, assetcategory, assettype, unitofmeasure, unitcost, totalunits FROM assets
                   WHERE pid=%s''' % project.pid
                   
     assets = database.execSelectQuery( query )
     
     database.close()
     
     ihmFile = open(filename, 'a')
     for asset in assets:
         assetline = '''INSERT INTO assets (pid, hhid, assetcategory, assettype, unitofmeasure, unitcost, totalunits )
             VALUES({pid},%s,'%s','%s','%s',%s,%s)<endl>\n''' % (asset[0], asset[1], asset[2], asset[3], asset[4], asset[5])
         ihmFile.write(assetline)
     ihmFile.close()
开发者ID:r4vi,项目名称:open-ihm,代码行数:19,代码来源:openihmexportmanager1.py

示例12: exportHouseholdWildfoodsIncome

# 需要导入模块: from model.database import Database [as 别名]
# 或者: from model.database.Database import close [as 别名]
 def exportHouseholdWildfoodsIncome(self, project, filename):
     database = Database()
     database.open()
     
     query = '''SELECT hhid, incomesource, unitofmeasure, unitsproduced, unitssold, unitprice, otheruses, unitsconsumed FROM wildfoods
                   WHERE pid=%s''' % project.pid
                   
     items = database.execSelectQuery( query )
     
     database.close()
     
     ihmFile = open(filename, 'a')
     for item in items:
         wfline = '''INSERT INTO wildfoods(pid, hhid, incomesource, unitofmeasure, unitsproduced, unitssold, unitprice, otheruses, unitsconsumed)
             VALUES({pid},%s,'%s','%s',%s,%s,%s,%s,%s)<endl>\n''' % (item[0],  item[1], item[2], item[3], item[4], item[5], item[6], item[7])
         ihmFile.write(wfline)
     ihmFile.close()
开发者ID:r4vi,项目名称:open-ihm,代码行数:19,代码来源:openihmexportmanager1.py

示例13: exportProjectStandardOfLiving

# 需要导入模块: from model.database import Database [as 别名]
# 或者: from model.database.Database import close [as 别名]
 def exportProjectStandardOfLiving(self, project, filename):
     database = Database()
     database.open()
     
     query = '''SELECT summary, scope, gender, agebottom, agetop, item, costperyear FROM standardofliving
                   WHERE pid=%s''' % project.pid
                   
     stdLvs = database.execSelectQuery( query )
     
     database.close()
     
     ihmFile = open(filename, 'a')
     for stdLv in stdLvs:
         stdLvline = '''INSERT INTO standardofliving (pid, summary, scope, gender, agebottom, agetop, item, costperyear )
             VALUES({pid},'%s','%s','%s',%s,%s,'%s',%s)<endl>\n''' % (stdLv[0], stdLv[1], stdLv[2], stdLv[3], stdLv[4], stdLv[5], stdLv[6])
         ihmFile.write(stdLvline)
     ihmFile.close()
开发者ID:r4vi,项目名称:open-ihm,代码行数:19,代码来源:openihmexportmanager1.py

示例14: existsCorrespondingIhmProject

# 需要导入模块: from model.database import Database [as 别名]
# 或者: from model.database.Database import close [as 别名]
 def existsCorrespondingIhmProject(self, projectname, startdate,  currency):
     ''' Checks if the project was transfered before '''
     
     query = '''SELECT projects.pid FROM projects, transferlog WHERE projects.pid=transferlog.pid
                  AND transferlog.projectname='%s' AND transferlog.datecollected='%s' 
                  AND transferlog.currency='%s' ''' % (projectname,  startdate, currency)
                  
     db = Database()
     db.open() 
     records = db.execSelectQuery( query )
     
     exists = False
     if len(records) == 1:
         exists = True
    
     db.close()
     return exists
开发者ID:r4vi,项目名称:open-ihm,代码行数:19,代码来源:openihmimportmanager1.py

示例15: exportHouseholdCharacteristics

# 需要导入模块: from model.database import Database [as 别名]
# 或者: from model.database.Database import close [as 别名]
 def exportHouseholdCharacteristics(self, project, filename):
     database = Database()
     database.open()
     
     query = '''SELECT hhid, characteristic, charvalue FROM householdcharacteristics
                   WHERE pid=%s''' % project.pid
                   
     chars = database.execSelectQuery( query )
     
     database.close()
     
     ihmFile = open(filename, 'a')
     for char in chars:
         charline = '''INSERT INTO householdcharacteristics (pid,hhid, characteristic, charvalue )
             VALUES({pid},%s,'%s','%s')<endl>\n'''  % (char[0], char[1], char[2])
         ihmFile.write(charline)
     ihmFile.close()
开发者ID:r4vi,项目名称:open-ihm,代码行数:19,代码来源:openihmexportmanager1.py


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