retrieve ADOConnection from _ADODB_Active_DBs
502678
function DB()
	{
	global $_ADODB_ACTIVE_DBS;

		if ($this->_dbat < 0) {
			$false = false;
			$this->Error("No database connection set: use ADOdb_Active_Record::SetDatabaseAdaptor(\$db)", "DB");
			return $false;
		}
		$activedb = $_ADODB_ACTIVE_DBS[$this->_dbat];
		$db = $activedb->db;
		return $db;
	}
1103475
def __connect(self):
        
        self.__methods     = _get_methods_by_uri(self.sqluri)
        uri_connect_method = self.__methods[METHOD_CONNECT]

        self.__dbapi2_conn = uri_connect_method(self.sqluri)
1159020
public function db_connect($persistent = FALSE)
	{
		$error = NULL;
		$conn_id = ($persistent === TRUE)
			? sqlite_popen($this->database, 0666, $error)
			: sqlite_open($this->database, 0666, $error);

		isset($error);

		return $conn_id;
	}
278444
def get_active() -> List[str]:
        """"""
        active = []
        for i in range(__num_subarrays__):
            key = Subarray.get_key(i)
            if DB.get_hash_value(key, 'active').upper() == 'TRUE':
                active.append(Subarray.get_id(i))
        return active
929604
def getConnectionStats(self):
        
        cur = self._conn.cursor()
        cur.execute("""SELECT datname,numbackends FROM pg_stat_database;""")
        rows = cur.fetchall()
        if rows:
            return dict(rows)
        else:
            return {}
342228
protected DatabaseConnection getSavedConnection() {
		NestedConnection nested = specialConnection.get();
		if (nested == null) {
			return null;
		} else {
			return nested.connection;
		}
	}
970916
function _connect($dsn)
    {
        if (is_string($dsn) || is_array($dsn)) {
        	if(!$this->db) {
	        	$this->db = ADONewConnection($dsn);
	    		if( $err = ADODB_Pear_error() ) {
	   	    		return PEAR::raiseError($err);
	    		}
        	}

        } else {
            return PEAR::raiseError('The given dsn was not valid in file ' . __FILE__ . ' at line ' . __LINE__,
                                    41,
                                    PEAR_ERROR_RETURN,
                                    null,
                                    null
                                    );
        }

        if(!$this->db) {
        	return PEAR::raiseError(ADODB_Pear_error());
        } else {
        	return true;
        }
    }
55739
def get_connection(self, key, host, port, user, password, dbname, ssl, connect_fct, tags, use_cached=True):
        """"""
        if key in self.dbs and use_cached:
            return self.dbs[key]

        elif host != "" and user != "":
            try:
                if host == 'localhost' and password == '':
                    # Use ident method
                    connection = connect_fct("user=%s dbname=%s" % (user, dbname))
                elif port != '':
                    connection = connect_fct(
                        host=host, port=port, user=user, password=password, database=dbname, ssl=ssl
                    )
                elif host.startswith('/'):
                    # If the hostname starts with /, it's probably a path
                    # to a UNIX socket. This is similar behaviour to psql
                    connection = connect_fct(unix_sock=host, user=user, password=password, database=dbname)
                else:
                    connection = connect_fct(host=host, user=user, password=password, database=dbname, ssl=ssl)
                self.dbs[key] = connection
                return connection
            except Exception as e:
                message = u'Error establishing postgres connection: %s' % (str(e))
                service_check_tags = self._get_service_check_tags(host, port, tags)
                self.service_check(
                    self.SERVICE_CHECK_NAME, AgentCheck.CRITICAL, tags=service_check_tags, message=message
                )
                raise
        else:
            if not host:
                raise ConfigurationError('Please specify a Postgres host to connect to.')
            elif not user:
                raise ConfigurationError('Please specify a user to connect to Postgres as.')
301464
def get_connection(connection_details=None):
    

    if connection_details is None:
        connection_details = get_default_connection_details()

    return MySQLdb.connect(
        connection_details['host'],
        connection_details['user'],
        connection_details['password'],
        connection_details['database']
    )
1173020
function _connect($argDSN, $argUsername, $argPassword, $argDatabasename)
  {
          global $php_errormsg;

    if (!function_exists('ads_connect')) return null;

    if ($this->debug && $argDatabasename && $this->databaseType != 'vfp') {
      ADOConnection::outp("For Advantage Connect(), $argDatabasename is not used. Place dsn in 1st parameter.");
    }
    if (isset($php_errormsg)) $php_errormsg = '';
    if ($this->curmode === false) $this->_connectionID = ads_connect($argDSN,$argUsername,$argPassword);
    else $this->_connectionID = ads_connect($argDSN,$argUsername,$argPassword,$this->curmode);
    $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
    if (isset($this->connectStmt)) $this->Execute($this->connectStmt);

    return $this->_connectionID != false;
  }
1172584
def get_conn(filename):
    """"""
    conn = sqlite3.connect(filename)
    conn.row_factory = _dict_factory
    return conn
200506
def _get_new_connection(self, conn_params):
    """"""
    self.__connection_string = conn_params.get('connection_string', '')
    conn = self.Database.connect(**conn_params)
    return conn
613383
def connectWithAdminInfo(path=None):
    """"""

    if path is None:
        path = os.path.expanduser('~/.cjdnsadmin')
    try:
        with open(path, 'r') as adminInfo:
            data = json.load(adminInfo)
    except IOError:
        logger.info('~/.cjdnsadmin not found; using default credentials', file=sys.stderr)
        data = {
            'password': 'NONE',
            'addr': '127.0.0.1',
            'port': 11234,
        }

    return connect(data['addr'], data['port'], data['password'])
625233
def get_db_session(engine):
    ""

    db = scoped_session(sessionmaker(extension=ZopeTransactionExtension()))
    db.configure(bind=engine)
    db.autoflush = True

    return db
728890
def getdb(backend=None, **kwargs):
    ''''''
    if isinstance(backend, BackendDataServer):
        return backend
    backend = backend or settings.DEFAULT_BACKEND
    if not backend:
        return None
    scheme, address, params = parse_backend(backend)
    params.update(kwargs)
    if 'timeout' in params:
        params['timeout'] = int(params['timeout'])
    return _getdb(scheme, address, params)
159030
protected Connection getConnectionQuite(DataSource ds) {
		try {
			return Trans.getConnectionAuto(ds);
		} catch (SQLException e) {
			throw new RuntimeException(e);
		}
	}
892947
private MariaDbPooledConnection getIdleConnection(long timeout, TimeUnit timeUnit)
      throws InterruptedException {

    while (true) {
      MariaDbPooledConnection item =
              (timeout == 0) ? idleConnections.pollFirst() : idleConnections.pollFirst(timeout, timeUnit);

      if (item != null) {
        MariaDbConnection connection = item.getConnection();
        try {
          if (TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - item.getLastUsed().get())
                  > options.poolValidMinDelay) {

            //validate connection
            if (connection.isValid(10)) { //10 seconds timeout
              item.lastUsedToNow();
              return item;
            }

          } else {

            // connection has been retrieved recently -> skip connection validation
            item.lastUsedToNow();
            return item;

          }

        } catch (SQLException sqle) {
          //eat
        }

        totalConnection.decrementAndGet();

        // validation failed
        silentAbortConnection(item);
        addConnectionRequest();
        if (logger.isDebugEnabled()) {
          logger.debug(
                  "pool {} connection removed from pool due to failed validation (total:{}, active:{}, pending:{})",
                  poolTag, totalConnection.get(), getActiveConnections(), pendingRequestNumber.get());
        }
        continue;
      }

      return null;

    }
  }