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()
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()
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()
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()
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()
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()
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
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
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
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
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)
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()
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 )
def __init__(self, parent): ''' Set up the dialog box interface ''' QDialog.__init__(self) self.setupUi(self) self.parent = parent self.config = Config.dbinfo().copy()
def test_dbinfo(self): Config.set_config(dummy_config()) self.assertEqual(Config.dbinfo(), {'a': 'b'})
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()
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
def __init__(self): self.database = Database() self.config = Config.dbinfo().copy()