def _database_connection(self): #Creates a databaase connection object from the specified args host = self.txtHost.text() port = self.txtPort.text() database = self.txtDatabase.text() #Create database connection object db_conn = DatabaseConnection(host, port, database) return db_conn
def read(self) -> Optional[DatabaseConnection]: """ Get the database connection properties """ db_props = self.reg_config.read( [DatabaseConfig.HOST, DatabaseConfig.PORT, DatabaseConfig.DB_NAME]) if len(db_props) < 3: return None else: return DatabaseConnection(db_props[DatabaseConfig.HOST], db_props[DatabaseConfig.PORT], db_props[DatabaseConfig.DB_NAME])
def acceptdlg(self): """ On user clicking the login button """ isValid = self.validateInput() if isValid: # Capture DB connection properties host = self.txtHost.text() port = self.txtPort.text() database = self.txtDatabase.text() dbconfig = DatabaseConfig() try: self.dbconn = DatabaseConnection(host, port, database) # Write DB conn object to the registry dbconfig.write(self.dbconn) except Exception as ex: QMessageBox.critical(self, QApplication.translate("DbConnectionDialog", "Error saving settings"), QApplication.translate("DbConnectionDialog", unicode(ex.message))) self.accept()
def create_db_connection(): db_conn = DatabaseConnection(DB_SERVER, DB_PORT, DB_NAME) user = User(DB_USER, DB_PASS) db_conn.User = user return db_conn