def __init__(self, parent):
	    ''' Set up the dialog box interface '''
	    self.parent = parent
	    QDialog.__init__(self)
	    self.setupUi(self)
	    self.parent = parent
	    self.config = Config.dbinfo().copy()
	    
	    # get food energy requirement details by sex and age
	    self.getFoodEnergyRequirements()
Esempio n. 2
0
 def __init__(self, parent):
     ''' Set up the dialog box interface '''
     QDialog.__init__(self)
     self.setupUi(self)
     self.parent = parent
     
     self.config = Config.dbinfo().copy()
     
     # get projects
     self.getHouseholds()
Esempio n. 3
0
	def __init__(self, parent):
	    ''' Set up the dialog box interface '''
	    self.parent = parent
	    QDialog.__init__(self)
	    self.setupUi(self)
	    self.parent = parent
	    self.config = Config.dbinfo().copy()
	    
	    self.lblProjectName.setText( self.parent.projectname ) 
	    # get current project details
	    self.getHouseholds()
Esempio n. 4
0
 def executeUpdateQuery(self, query):
     """Execute a query that needs to be committed to the database.
     For example, an INSERT or UPDATE query.
     """
     config = Config.dbinfo().copy()
     db = connector.Connect(**config)             
     cursor = db.cursor()
     cursor.execute(query)
     db.commit()
     cursor.close()
     db.close()
     return
 def __init__(self, parent):
     ''' Set up the dialog box interface '''
     self.parent = parent
     QDialog.__init__(self)
     self.setupUi(self)
     self.parent = parent
     self.currentitem = ""
     
     # connect to database
     self.config = Config.dbinfo().copy()
     
     self.listItems()
Esempio n. 6
0
    def __init__(self, parent):
        """ Set up the dialog box interface """
        self.parent = parent
        QDialog.__init__(self)
        self.setupUi(self)
        self.parent = parent
        self.currencyid = 0

        # connect to database
        self.config = Config.dbinfo().copy()

        self.listCurrencies()
Esempio n. 7
0
	def __init__(self, parent, hhid = "", hhname = ""):
		''' Set up the dialog box interface '''
		QDialog.__init__(self)
		self.setupUi(self)
		self.parent = parent
		self.config = Config.dbinfo().copy()
		
		self.lblProjectName.setText( self.parent.projectname ) 
		self.txtHouseholdNo.setText( hhid )
		self.txtHouseholdName.setText ( hhname )
		
		self.getHouseholds()
Esempio n. 8
0
 def executeResultsQuery(self, query):
     """Execute a query for which the database will return results.
     For example a SELECT query.
     """
     config = Config.dbinfo().copy()
     db = connector.Connect(**config)
     cursor = db.cursor()
     cursor.execute(query)
     results = cursor.fetchall()
     cursor.close()
     db.close()
     return results
Esempio n. 9
0
 def executeMultipleUpdateQueries(self, queries):
     """This method is idential to self.executeUpdateQuery
     except that it takes a list of query strings and executes each in turn
     """
     config = Config.dbinfo().copy()
     db = connector.Connect(**config)
     cursor = db.cursor()
     for query in queries:
         cursor.execute(query)
         db.commit()
     cursor.close()
     db.close()
     return
Esempio n. 10
0
 def executeUpdateQuery(self, query, params=None):
     """Execute a query that needs to be committed to the database.
     For example, an INSERT or UPDATE query.
     """
     config = Config.dbinfo().copy()
     db = connector.Connect(**config)
     cursor = db.cursor()
     converted_qt = ParamsUtility.make_parameters_safe(params)
     cursor.execute(query, converted_qt)
     db.commit()
     cursor.close()
     db.close()
     return
Esempio n. 11
0
 def executeMultipleResultsQueries(self, queries):
     """This method is idential to self.executeResultsQuery
     except that it takes a list of query strings, executes each in turn
     and returns a corresponding list of results.
     """
     results = []
     config = Config.dbinfo().copy()
     db = connector.Connect(**config)
     cursor = db.cursor()
     for query in queries:
         cursor.execute(query)
         result = cursor.fetchall()
         results.append(result)
     cursor.close()
     db.close()
     return results
Esempio n. 12
0
    def __init__(self, parent,  hhid, hhname, expid = 0 ):
		''' Set up the dialog box interface '''
		QDialog.__init__(self)
		self.setupUi(self)
		self.parent 	= parent
		self.pid  = parent.parent.projectid
		self.hhid 		= hhid
		self.expid 		= expid
		
		self.config = Config.dbinfo().copy()
		
		self.getExpenditureTypes()
		
		if ( expid != 0 ):
			self.displayExpenditureDetails()
			self.setWindowTitle( "Edit Household Expenditure" )
		  
		# display household name
		self.lblHouseholdName.setText(hhname)
     def __init__(self, parent,  hhid, hhname, incomeid = 0 ):
         ''' Set up the dialog box interface '''
         QDialog.__init__(self)
         self.setupUi(self)
         self.parent 	= parent
         self.hhid 		= hhid
         self.pid = parent.parent.projectid
         self.incomeid 	= incomeid

         self.config = Config.dbinfo().copy()

         self.getGiftsTypes()
         self.getCropTypes()

         if ( incomeid != 0 ):
             self.displayIncomeDetails()
             self.setWindowTitle( "Edit Income Item" )

         # display household name
         self.lblHouseholdName.setText(hhname)
Esempio n. 14
0
    def __init__(self, parent, hhid, hhname, memberid):
        """ Set up the dialog box interface """
        QDialog.__init__(self)
        self.setupUi(self)
        self.parent = parent
        self.hhid = hhid
        self.currentid = memberid

        # configure connect to database
        self.config = Config.dbinfo().copy()

        # add years to the year of birth combo box: current year to 150 years ago
        thisyear = date.today().year
        for year in range(thisyear, thisyear - 151, -1):
            self.cmbYearOfBirth.addItem("%i" % year)

        # display household name
        self.lblHouseholdName.setText(hhname)

        # get and display member details
        self.getMemberDetails()
Esempio n. 15
0
 def __init__(self, parent,  hhid, hhname, incomeid = 0 ):
     ''' Set up the dialog box interface '''
     QDialog.__init__(self)
     self.setupUi(self)
     self.parent 	= parent
     self.hhid 		= hhid
     self.pid = parent.parent.projectid
     self.incomeid 	= incomeid
     
     self.config = Config.dbinfo().copy()
     
     self.getCropTypes()
     
     if ( incomeid != 0 ):
         self.displayIncomeDetails()
         self.setWindowTitle( "Edit Income Item" )
         
     # display household name
     self.lblHouseholdName.setText(hhname)
     
     # lock editing of income source and unit of measure
     self.cboIncomeType.setEditable( False )
     self.txtUnitOfMeasure.setReadOnly( True )
Esempio n. 16
0
	def __init__(self, parent):
		''' Set up the dialog box interface '''
		QDialog.__init__(self)
		self.setupUi(self)
		self.parent = parent
		self.config = Config.dbinfo().copy()
Esempio n. 17
0
 def test_dbinfo(self):
     Config.set_config(dummy_config())
     self.assertEqual(Config.dbinfo(), {'a': 'b'})
Esempio n. 18
0
 def __init__(self,projectid):
     self.database = Database()
     self.pcharstable = 'p' + str(projectid) +'PersonalCharacteristics'
     self.hcharstable = 'p' + str(projectid) +'HouseholdCharacteristics'
     self.pid = projectid
     self.config = Config.dbinfo().copy()
Esempio n. 19
0
	def __init__(self,query):
		# connect to mysql database
		self.config = Config.dbinfo().copy()        	
		self.db = connector.Connect(**self.config)
        	self.cursor = self.db.cursor()		
		self.sqlquery = query
Esempio n. 20
0
 def __init__(self):
     self.database = Database()
     self.config = Config.dbinfo().copy()