Open the connection to the database based on the configuration file.
499440
def _get_db(self):
        
        if self._connection:
            try:
                self._connection.close()
            except Exception:
                pass

        return DB(storageFromFile(open(self.conf_path)))
193763
def open(self, writeAccess=False):
        
        host = self.database().writeHost() if writeAccess else self.database().host()
        pool = self.__pool[host]

        if self.__poolSize[host] >= self.__maxSize or pool.qsize():
            if pool.qsize() == 0:
                log.warning('Waiting for connection to database!!!')
            return pool.get()
        else:
            db = self.database()

            # process a pre-connect event
            event = orb.events.ConnectionEvent()
            db.onPreConnect(event)

            self.__poolSize[host] += 1
            try:
                conn = self._open(self.database(), writeAccess=writeAccess)
            except Exception:
                self.__poolSize[host] -= 1
                raise
            else:
                event = orb.events.ConnectionEvent(success=conn is not None, native=conn)
                db.onPostConnect(event)
                return conn
72192
public function openConnection(): void
    {
        $this->closeConnection();
        $this->currentLink = @new \mysqli($this->databaseHost, $this->databaseUser, $this->databasePass);

        if (!$this->currentLink->connect_error) {
            $this->isConnected = true;
            $this->connectionCount += 1;
        } else {
            $this->setError(AbstractMySQL::E_NO_CONNECTION, __CLASS__);
        }
    }
657127
def _open_sqlite(db_file):
    """"""
    db_file = os.path.expanduser(db_file)
    try:
        with open(db_file):
            # test that the file can be accessed
            pass
        return sqlite3.connect(db_file, detect_types=sqlite3.PARSE_DECLTYPES)
    except (IOError, sqlite3.Error) as err:
        raise Dump2PolarionException("{}".format(err))
936419
def open(self, options=None, mimetype='application/octet-stream'):
        
        return self.connection.open(self, options, mimetype)
1355379
def init_db(db_path):
    """"""
    logger.info("Creating database")
    with closing(connect_database(db_path)) as db:
        with open(SCHEMA, 'r') as f:
            db.cursor().executescript(f.read())
        db.commit()
    return
1087612
public final function open() : Connection
   {

      if ( $this->isOpen() )
      {
         return $this;
      }

      $attrSupport       = $this->_driver->getAttributeSupport();
      $definedAttributes = $this->_driver->getDefinedAttributes();


      $dsn  = $this->_driver->getType() . ':';
      $dsnC = 0;
      $user = null;
      $pass = null;
      $sql  = [];
      $opts = [];

      foreach( $definedAttributes as $attrName => $attrValue )
      {

         $attrDesc = $attrSupport->get( $attrName );

         if ( null === $attrDesc ) { continue; }

         switch ( $attrDesc->getType() )
         {

            case Type::DSN_PART:
               if ( $dsnC < 1 )
               {
                  $dsnC++;
               }
               else
               {
                  $dsn .= $attrSupport->getDSNAttributeSeparator();
               }
               if ( $attrDesc->useNameInDSN() )
               {
                  $dsn .= $attrName . $attrSupport->getDSNKeyValueSeparator();
               }
               $dsn .= $attrValue;
               break;

            case Type::USERNAME_PARAM:
               $user = $attrValue;
               break;

            case Type::PASSWORD_PARAM:
               $pass = $attrValue;
               break;

            case Type::OPTION_PARAM:
               $opts[ $attrName ] = $attrValue;
               break;

            #case Type::INIT_SQL:
            default:
               if ( 'charset' === $attrName )
               {
                  $sql[] = 'SET NAMES ' . $attrValue;
                  break;
               }
               $sql[] = $attrValue;
               break;

         }

      }

      try
      {
         if ( ! isset( $opts[ \PDO::ATTR_ERRMODE ] ) )
         {
            $opts[ \PDO::ATTR_ERRMODE ] = \PDO::ERRMODE_EXCEPTION;
         }
         if ( $this->_driver->getType() === 'sqlite' || ( null === $user && null === $pass ) )
         {
            $this->_pdo = new \PDO( $dsn, null, null, $opts );
         }
         else
         {
            $this->_pdo = new \PDO( $dsn, $user, $pass, $opts );
         }
      }
      catch ( \Throwable $ex )
      {
         throw new ConnectionException( $this->_driver, 'Connection init fails!', 256, $ex );
      }

      if ( 0 < \count( $sql ) )
      {

         foreach ( $sql as $sqlString )
         {
            try { $this->_pdo->exec( $sqlString ); }
            catch ( \Throwable $ex )
            {
               throw new QueryException(
                  $this->_driver, $sqlString, [], 'Can not call the initial query!', 256, $ex
               );
            }
         }

      }

      return $this;

   }
276271
function open()
    {
        if (is_resource($this->_db)) {
            $this->_opened = true;
            return $this->_createTable();
        } else {
            /* Set the connection function based on the 'persistent' option. */
            if (empty($this->_options['persistent'])) {
                $connectFunction = 'sqlite_open';
            } else {
                $connectFunction = 'sqlite_popen';
            }

            /* Attempt to connect to the database. */
            if ($this->_db = $connectFunction($this->_options['filename'],
                                              (int)$this->_options['mode'],
                                              $error)) {
                $this->_opened = true;
                return $this->_createTable();
            }
        }

        return $this->_opened;
    }
1207383
function open()
    {
        if (!$this->_opened) {
            /* Use the DSN and options to create a database connection. */
            $this->_db = &DB::connect($this->_dsn, $this->_options);
            if (DB::isError($this->_db)) {
                return false;
            }

            /* Create a prepared statement for repeated use in log(). */
            if (!$this->_prepareStatement()) {
                return false;
            }

            /* We now consider out connection open. */
            $this->_opened = true;
        }

        return $this->_opened;
    }
244508
public void open() throws SQLException, ClassNotFoundException {
        logger.info("Using database driver: " + jdbcDriver);
        Class.forName(jdbcDriver);
        logger.info("Using database.url: " + jdbcURL);
        // connect login/pass
        con = DriverManager.getConnection(jdbcURL, user, password);
        // Exception will be thrown if something went wrong
        connected = true;
    }
735327
def open(self):
        """"""
        self._id = str(uuid.uuid4())
        self._client.open_connection(self._id, info=self._connection_args)
615996
public void open() throws DBException
    {
        if (m_JDBCConnection == null)
        {
            String strJdbcDriver = this.getProperty(SQLParams.JDBC_DRIVER_PARAM);
            if ((strJdbcDriver == null) || (strJdbcDriver.length() == 0))
            { // If a JDBC driver isn't specified, set up for the default driver
                String strDataSource = this.getProperty(SQLParams.DATASOURCE_PARAM);
                if (strDataSource == null)
                    strDataSource = this.getProperty(SQLParams.DEFAULT_DATASOURCE_PARAM);
                if (strDataSource == null)
                    strDataSource = SQLParams.DEFAULT_DATASOURCE;
                boolean bDataSourceConnection = false;
                if (strDataSource != null)
                    bDataSourceConnection = this.setupDataSourceConnection(strDataSource);

                String strDatabaseProductName = null;
                try {
					if (m_JDBCConnection != null)
					{
						strDatabaseProductName = m_JDBCConnection.getMetaData().getDatabaseProductName();
						strDatabaseProductName = this.fixDatabaseProductName(strDatabaseProductName);
					}
				} catch (SQLException e) {
					e.printStackTrace();
				}
                if ((strDatabaseProductName == null) || (strDatabaseProductName.length() == 0))
                	strDatabaseProductName = this.getProperty(SQLParams.DATABASE_PRODUCT_PARAM);
                if ((strDatabaseProductName == null) || (strDatabaseProductName.length() == 0))
                    strDatabaseProductName = DEFAULT_DATABASE_PRODUCT;
                this.setProperty(SQLParams.INTERNAL_DB_NAME, strDatabaseProductName);
                this.setupDatabaseProperties(); // If I haven't read the db properties, read them now!

                if (!bDataSourceConnection)
                {	// Datasource connection could be supplied in the db properties
                    String strDBDataSource = this.getProperty(SQLParams.DATASOURCE_PARAM);
                    if (strDBDataSource == null)
                    	strDBDataSource = this.getProperty(SQLParams.DEFAULT_DATASOURCE_PARAM);
                    if (strDBDataSource != null)
                    	if (!strDBDataSource.equalsIgnoreCase(strDataSource))
                        	bDataSourceConnection = this.setupDataSourceConnection(strDBDataSource);                	
                }
                if (!bDataSourceConnection)
                    bDataSourceConnection = this.setupDirectDataSourceConnection();
                if (!bDataSourceConnection)
                {
                    strJdbcDriver = this.getProperty(SQLParams.JDBC_DRIVER_PARAM);  // Default driver
                    if (strJdbcDriver == null)
                        strJdbcDriver = this.getProperty(BASE_DATABASE_JDBC_DRIVER);    // Special case - base database
                }
            }
            if (strJdbcDriver != null)
                this.setupJDBCConnection(strJdbcDriver);
            this.initConnection();
            this.loadDatabaseProperties();
        }
        
        super.open(); // Do any inherited
    }
1178899
def _open_connection(self):
        
        if self._connection:
            try:
                self._connection.close()
            except Exception:
                pass

        db = self._get_db()
        self._connection = db.open()

        self._connection.onCloseCallback(self._on_close_callback)
1085006
function open()
    {
        if (!$this->_opened) {
            /* Use the DSN and options to create a database connection. */
            $this->_db = &MDB2::connect($this->_dsn, $this->_options);
            if (PEAR::isError($this->_db)) {
                return false;
            }

            /* Create a prepared statement for repeated use in log(). */
            if (!$this->_prepareStatement()) {
                return false;
            }

            /* We now consider out connection open. */
            $this->_opened = true;
        }

        return $this->_opened;
    }
531122
def _open_connection(self):
        
        if self._scheme == 'unix':
            self._connection = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM, 0)
            self._connection.connect(self._path)
        elif self._scheme == 'tcp':
            self._connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.SOL_TCP)
            self._connection.connect((self._host, self._port))
        elif self._scheme == 'http':
            self._connection =  httplib.HTTPConnection(self._host, self._port, strict=False)
        else:
            raise ConnectionError("Connection scheme not recognized!")
633656
public void open() {
        if(sqlSession == null) {
            if (executorType == null) {
                executorType = ExecutorType.SIMPLE;
            }

            sqlSession = sqlSessionFactory.openSession(executorType, autoCommit);

            if (log.isDebugEnabled()) {
                ToStringBuilder tsb = new ToStringBuilder(String.format("%s %s@%x",
                        (arbitrarilyClosed ? "Reopened" : "Opened"),
                        sqlSession.getClass().getSimpleName(),
                        sqlSession.hashCode()));
                tsb.append("executorType", executorType);
                tsb.append("autoCommit", autoCommit);
                log.debug(tsb.toString());
            }

            arbitrarilyClosed = false;
        }
    }
1283477
def _open(self):
        
        try:
            self.db = connect(
                host=self.settings.host,
                port=self.settings.port,
                user=coalesce(self.settings.username, self.settings.user),
                passwd=coalesce(self.settings.password, self.settings.passwd),
                db=coalesce(self.settings.schema, self.settings.db),
                read_timeout=coalesce(self.settings.read_timeout, (EXECUTE_TIMEOUT / 1000) - 10 if EXECUTE_TIMEOUT else None, 5*60),
                charset=u"utf8",
                use_unicode=True,
                ssl=coalesce(self.settings.ssl, None),
                cursorclass=cursors.SSCursor
            )
        except Exception as e:
            if self.settings.host.find("://") == -1:
                Log.error(
                    u"Failure to connect to {{host}}:{{port}}",
                    host=self.settings.host,
                    port=self.settings.port,
                    cause=e
                )
            else:
                Log.error(u"Failure to connect.  PROTOCOL PREFIX IS PROBABLY BAD", e)
        self.cursor = None
        self.partial_rollback = False
        self.transaction_level = 0
        self.backlog = []  # accumulate the write commands so they are sent at once
        if self.readonly:
            self.begin()