Open the database connection.
191396
def open( self ):
        """"""
        if self._connection is None:
            self._connection = sqlite3.connect(self._dbfile)
648649
def open_connection(self):
        
        self.logger.debug("Open COM %s", self.comport)
        self.port = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        (ip_addr, port) = self.comport.split(':')
        self.port.connect(ip_addr, num(port))
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;
    }
1249605
public function initialize() : void
  {
    $connection = config('database.default');

    Accessor::$appRoot       = config('app.dir');
    UpstartConfig::$database = config("database.connections.{$connection}");

    if (!DB::start()) {
      $this->exception('Could not establish a database connection.');
    }

    $this->loadView();
  }
1055251
async def connect(self):
        
        self.pool = await aiomysql.create_pool(
            loop=self.loop,
            db=self.database,
            connect_timeout=self.timeout,
            **self.connect_params)
192661
protected function connectToDb()
    {
        try {
            $this->db = new PDO("mysql:dbname=;" . $this->db_host, $this->db_user, $this->db_pass);
            $this->db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
        } catch (\Exception $e) {
            $this->log("Cannot connect to database.  Are the credentials correct?");
            $this->log(print_r($e), 1);
            exit;
        }
    }
823120
def open(self, dbname=None):
        '''
        
        '''
        databases = self.list()
        if self.is_closed():
            self.db_path = os.path.join(self.path, dbname or (databases and databases[0] or self.new()))
            if not self._opened:
                self.list_tables()
                self._opened = True
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
    }
114244
public synchronized void connect_db() {

	//
	// Try to connect to the database
	//

	if (_daemon == true) {
	    boolean connected = false;
	    while (connected == false) {
		try {
		    db = ApiUtil.get_db_obj();
		    if (db == null) {
			Util.out4.println("Can't contact db server, will try later");
			try {
			    wait(_sleep_between_connect * 1000);
			} catch (final InterruptedException ex) {
			}
		    } else {
			connected = true;
		    }
		} catch (final Exception e) {
		    Util.out4.println("Can't contact db server, will try later");
		    try {
			wait(_sleep_between_connect * 1000);
		    } catch (final InterruptedException ex) {
		    }
		}
	    }
	} else {
	    try {
		db = ApiUtil.get_db_obj();
		if (db == null) {
		    System.err.println("Can't build connection to TANGO database server, exiting");
		    System.err.println("DB server host = " + db_host);
		    System.exit(-1);
		}

	    } catch (final Exception ex) {
		System.err.println("Can't build connection to TANGO database server, exiting");
		System.err.println("DB server host = " + db_host);
		System.exit(-1);
	    }
	}
	Util.out4.println("Connected to database");
    }
1174285
def connect(self):
        
        self._connection = StrictRedis(
            host=self._host,
            port=self._port,
            db=self._database,
            password=self._password)
657337
protected Connection openConnection() throws SQLException
   {
      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<Connection>()
      {
         public Connection run() throws SQLException
         {
            return ds.getConnection();
         }
      });
   }
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;
    }
1055202
def _connect(self):
        

        try:
            db = pymysql.connect(user=self.user, passwd=self.passwd,
                                 host=self.host, port=self.port,
                                 db=self.shdb, use_unicode=True)
            return db, db.cursor()
        except Exception:
            logger.error("Database connection error")
            raise
838691
def open(self):
        
        LOGGER.debug('Connection Opening')
        self.set_state(self.OPENING)
        self._exceptions = []
        self._channels = {}
        self._last_channel_id = None
        self._io.open()
        self._send_handshake()
        self._wait_for_connection_state(state=Stateful.OPEN)
        self.heartbeat.start(self._exceptions)
        LOGGER.debug('Connection Opened')
631843
def open_database(self):
        
        if not self.con:
            try:
                self.con = psycopg2.connect(host=self.host,
                    database=self.dbname, user=self.user,
                    password=self.password, port=self.port)
            except psycopg2.Error as e:
                print("Error while opening database:")
                print(e.pgerror)
180910
public void connectDatabase()
    {
        try 
        {
            _con = DriverManager.getConnection(_url, _userName, _password);
        }
        catch(SQLException e)
        {
            log.warn("UserRealm " + getName()
                      + " could not connect to database; will try later", e);
        }
    }
399977
protected function opendb() {
    // Only do one open
    
    if($this->db) {
      return $this->db;
    }

    $db = @mysql_connect($this->host, $this->user, $this->password, true);

    if(!$db) {
      throw new SqlException(__METHOD__ . ": Can't connect to database", $this);
    }

    $this->db = $db; // set this right away so if we get an error below $this->db is valid

    if(!@mysql_select_db($this->database, $db)) {
      throw new SqlException(__METHOD__ . " Can't select database", $this);
    }
    return $db;
  }