public function getSourceDatabase()
    {
        if (! $this->_sourceDb) {

            if ($dbConfig['dbname'] = $this->_sourceData['gso_ls_database']) {

                // Default config values from gemsDb
                $gemsConfig = $this->_gemsDb->getConfig();
                $gemsName   = $gemsConfig['dbname'];

                if (($dbConfig['dbname'] != $gemsName) &&
                    ($adapter = $this->_sourceData['gso_ls_adapter'])) {

                    //If upgrade has run and we have a 'charset' use it
                    if (array_key_exists('gso_ls_charset', $this->_sourceData)) {
                        $dbConfig['charset'] = $this->_sourceData['gso_ls_charset']
                                ? $this->_sourceData['gso_ls_charset']
                                : $gemsConfig['charset'];
                    }
                    $dbConfig['host']     = $this->_sourceData['gso_ls_dbhost']
                            ? $this->_sourceData['gso_ls_dbhost']
                            : $gemsConfig['host'];
                    if (isset($this->_sourceData['gso_ls_dbport'])) {
                        $dbConfig['port'] = $this->_sourceData['gso_ls_dbport'];
                    } elseif (isset($gemsConfig['port'])) {
                        $dbConfig['port'] = $gemsConfig['port'];
                    }
                    $dbConfig['username'] = $this->_sourceData['gso_ls_username']
                            ? $this->_sourceData['gso_ls_username']
                            : $gemsConfig['username'];
                    $dbConfig['password'] = $this->_sourceData['gso_ls_password']
                            ? $this->project->decrypt($this->_sourceData['gso_ls_password'])
                            : $gemsConfig['password'];

                    $this->_sourceDb = \Zend_Db::factory($adapter, $dbConfig);
                }
            }

            // In all other cases use $_gemsDb
            if (! $this->_sourceDb) {
                $this->_sourceDb = $this->_gemsDb;
            }
        }

        return $this->_sourceDb;
    }