Opens the session for a particular database
357615
@Override
    public IDocumentSession openSession(String database) {
        SessionOptions sessionOptions = new SessionOptions();
        sessionOptions.setDatabase(database);

        return openSession(sessionOptions);
    }
239866
function openDatabase (name) {
  var deferred = q.defer();

  // Make sure the file directory exists
  ready.then(function () {
    // Make note of an action on the database to avoid closing early
    actionOn(name);

    // If database exists in memory already, we're good to go
    if(databases[name]) return deferred.resolve();

    // If database isn't in memory, make sure it exists
    createDatabase(name).then(function () {
      // Read database
      fs.readFile(globalConfig.db.location + name + '.db.json', function (err, data) {
        if(err) return deferred.reject(err);

        // Hold database in memory
        databases[name] = JSON.parse(data);

        deferred.resolve();
      });
    }, function (err) {
      deferred.reject(err);
    });
  }, function () {
    deferred.reject('Database couldn\'t instantiate');
  });

  return deferred.promise;
}
739245
def initdb():
    """"""
    click.echo('Init the db...')
    db.create_all()

    for i in range(30):
        click.echo("Creating user/address combo #{}...".format(i))
        address = Address(description='Address#2' + str(i).rjust(2, "0"))
        db.session.add(address)
        user = User(name='User#1' + str(i).rjust(2, "0"))
        user.address = address
        db.session.add(user)
        sleep(1)
    db.session.commit()
836892
public function open()
    {
        if (version_compare(PHP_VERSION, '5.4', '>')) {
            if (session_status() == PHP_SESSION_NONE) {
                session_start();
            }
        } else {
            @session_start();
        }
        $this->is_opened = true;
        return $this;
    }
558916
def session(self):
        
        engine = self.engine
        connection = engine.connect()
        db_session = scoped_session(
            sessionmaker(autocommit=False, autoflush=True, bind=engine))
        yield db_session
        db_session.close()
        connection.close()
1122313
protected synchronized void registerOpenDatabase(DatabaseImpl newDB)
    {
        DatabaseImpl old_db = getCurrentDatabase();
        if (old_db != null)
        {
            try
            {
                if (old_db.isOpen())
                {
                    log.warn("## There is still an opened database, close old one ##");
                    old_db.close();
                }
            }
            catch (Throwable t)
            {
                //ignore
            }
        }
        if (log.isDebugEnabled()) log.debug("Set current database " + newDB + " PBKey was " + newDB.getPBKey());
        setCurrentDatabase(newDB);
//        usedDatabases.add(newDB.getPBKey());
    }
469329
def perform!(email, password, &block)
      login_required
      CaTissue::Database.current.open(email, password, &block)
    end
805904
def get(self, name, default=None):
        '''
        
        '''

        session = self.__get_session_from_db()

        return session.get(name, default)
1342126
def close_database_session(session):
    """"""

    try:
        session.close()
    except OperationalError as e:
        raise DatabaseError(error=e.orig.args[1], code=e.orig.args[0])
550394
def db(self):
        
        if self.database is NotImplemented:
            self.database = Session

        return self.database
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;
  }
151967
def in_session(self):
        """"""
        session = self.get_session()
        try:
            yield session
            session.commit()
        except IntegrityError:
            session.rollback()
            raise DuplicateError("Duplicate unique value detected!")
        except (OperationalError, DisconnectionError):
            session.rollback()
            self.close()
            logger.warn("Database Connection Lost!")
            raise DatabaseConnectionError()
        except Exception:
            session.rollback()
            raise
        finally:
            session.close()
150030
def open
      conn = connection.protocol::DbOpen.new(params(name: @name, storage: @storage, user: @user, password: @password)).process(connection)
      @session = conn[:session] || OrientdbBinary::OperationTypes::NEW_SESSION

      @clusters = conn[:clusters]
      self
    end
523549
def connect(url=None, schema=None, sql_path=None, multiprocessing=False):
    
    if url is None:
        url = os.environ.get("DATABASE_URL")
    return Database(url, schema, sql_path=sql_path, multiprocessing=multiprocessing)
230524
def __get_session(self):
        
        db_path = self.__get_config().get(ConfigKeys.asset_allocation_database_path)
        self.session = dal.get_session(db_path)
        return self.session
1129855
def unlock(self):
    """"""
    if not hasattr(self, 'session'):
      raise RuntimeError('Error detected! The session that you want to close does not exist any more!')
    logger.debug("Closed database session of '%s'" % self._database)
    self.session.close()
    del self.session
814990
def session(connection_string=None):
    """"""
    global _session_makers
    connection_string = connection_string or oz.settings["db"]

    if not connection_string in _session_makers:
        _session_makers[connection_string] = sessionmaker(bind=engine(connection_string=connection_string))

    return _session_makers[connection_string]()