def connect(self): try: self.config_dic = self.database_dialog.get_config_dic() self.database = SQLdb.database(self.config_dic['engine'], debug=self.debug) self.database.connect(database=self.config_dic['database'], driver=self.config_dic['driver'], host=self.config_dic['host'], user=self.config_dic['user'], password=self.config_dic['password']) self.database_dialog.set_connected() # Save .ini-file automatically on connection if self.autosave == True: self.save_settings_to_ini() except Exception, inst: self.DialogBox.show(dialog_type='error', title='Fehler', inst=inst) self.database_dialog.set_disconnected()
def connect(self): """ Trys to connect the database with given parameters. """ try: self.section_dict = self.get_content() self.database = SQLdb.database(self.section_dict.get("engine")) self.database.connect( database=self.section_dict.get("database"), driver=self.section_dict.get("driver"), host=self.section_dict.get("host"), user=self.section_dict.get("user"), password=self.section_dict.get("password"), filepath=self.section_dict.get("filepath"), ) self.set_connected() # Save .ini-file automatically on connection if self.autosave == True: self.save_settings() except Exception, inst: self.set_disconnected() self.ErrorDialog.show(message="Datenbank konnte nicht verbunden werden.", instance=inst)
def connect(self): ''' Trys to connect the database with given parameters. ''' try: self.section_dict = self.get_content() self.database = SQLdb.database(self.section_dict.get('engine')) self.database.connect(database=self.section_dict.get('database'), driver=self.section_dict.get('driver'), host=self.section_dict.get('host'), user=self.section_dict.get('user'), password=self.section_dict.get('password'), filepath=self.section_dict.get('filepath')) self.set_connected() # Save .ini-file automatically on connection if self.autosave == True: self.save_settings() except Exception, inst: self.set_disconnected() self.ErrorDialog.show( message='Datenbank konnte nicht verbunden werden.', instance=inst)