Obtain a handle for the database.  This allows lazy
        initialization of the database handle.
779434
def db(self):
        

        # Initialize the database handle; we're running in a separate
        # process, so we need to get_database() ourself
        if not self._db:
            self._db = self.config.get_database()

        return self._db
281754
public function getHandle()
    {
        if(!$handle = $this->getProperty($this->getIdentityColumn())) {
            $handle = parent::getHandle();
        }

        return $handle;
    }
803797
def _get_cursor(self):
        '''
        
        '''
        _options = self._get_options()
        conn = sqlcipher.connect(_options.get('database'),
                                 timeout=float(_options.get('timeout')))
        conn.execute('pragma key="{0}"'.format(_options.get('pass')))
        cursor = conn.cursor()
        try:
            yield cursor
        except sqlcipher.Error as err:
            log.exception('Error in ext_pillar SQLCipher: %s', err.args)
        finally:
            conn.close()
1218824
public function getHandle()
    {
        if (!isset($this->handle) && $this->fieldId) {
            $field = Craft::$app->fields->getFieldById($this->fieldId);
            
            foreach ($field->getBlockTypes() as $index => $blockType) {
                if ($blockType->id == $this->id) {
                    $this->handle = $field->handle . '-' . $index;
                    break;
                }
            }
        }

        return $this->handle;
    }
648845
def handle(self):
        
        if not self.confirm_to_proceed(
            "<question>Are you sure you want to refresh the database?:</question> "
        ):
            return

        database = self.option("database")

        options = [("--force", True)]

        if self.option("path"):
            options.append(("--path", self.option("path")))

        if database:
            options.append(("--database", database))

        if self.get_definition().has_option("config"):
            options.append(("--config", self.option("config")))

        self.call("migrate:reset", options)

        self.call("migrate", options)

        if self._needs_seeding():
            self._run_seeder(database)
148558
def _new_empty_handle():
    
    hdl = NDArrayHandle()
    check_call(_LIB.MXNDArrayCreateNone(ctypes.byref(hdl)))
    return hdl
277287
@Override
    public void handle() throws HandlerException {
        String repository = getAuditEvent().getRepository();
        boolean writeInDefaultTable = !separate || repository == null;
        String tableName = writeInDefaultTable ? default_table_name : generateTableName(repository);

        getDaoForTable(tableName).writeEvent(getAuditEvent());
    }
357875
def init_db(self):
    '''
    '''

    # The user can provide a custom string
    if self.database is None:
        self.logger.error("You must provide a database url, exiting.")
        sys.exit(1)

    self.engine = create_engine(self.database, convert_unicode=True)
    self.session = scoped_session(sessionmaker(autocommit=False,
                                               autoflush=False,
                                               bind=self.engine))

    # Database Setup
    Base.query = self.session.query_property()

    # import all modules here that might define models so that
    # they will be registered properly on the metadata.  Otherwise
    # you will have to import them first before calling init_db()
    import expfactory.database.models
    self.Base = Base
    self.Base.metadata.create_all(bind=self.engine)
975063
private function _loadDatabase()
    {
        if (!isset(self::$db[$this->name])) {
            $config = Config::config()->{$this->name};
            if(!is_array($config))
                throw new \Exception ($config . ' not a valid db config');
            // Load database
            $db = new Database($config);

            self::$db[$this->name] = $db;
            self::$prefix = isset($config['prefix']) ? $config['prefix'] : '';
        }

        return $this->getDb();
    }
1313528
def get_object_handle(self, obj):
        
        if obj not in self._object_handles:
            self._object_handles[obj] = self._get_object_handle(obj=obj)

        return self._object_handles[obj]
1303643
def get_database(obj, **params):
    """"""
    if isinstance(obj, string_types):
        return connect(obj, **params)
    return obj
1215662
public synchronized Database get_db_obj() throws DevFailed {
        if (ApiUtil.getOrb() == null) {
            create_orb();
        }

        // If first time, create vector
        // ---------------------------------------------------------------
        if (db_list == null) {
            db_list = new ArrayList<Database>();
        }
        // If first time, create Database object
        // -----------------------------------------------------------
        if (defaultDatabase == null) {
            defaultDatabase = new Database();
            db_list.add(defaultDatabase);
        }
        return db_list.get(0);
    }
1101872
public Object handleGetObject(String strKey)
    {
        String strValue = null;
        try   {
            strValue = m_resourceBundle.getString(strKey);
        } catch (MissingResourceException ex) {
            strValue = DBConstants.BLANK;
        } catch (NullPointerException ex) {
            strValue = DBConstants.BLANK;
        }
        if ((strValue == null) || (strValue == DBConstants.BLANK))
            if (m_bReturnKeyOnMissing)
                if (strKey != null)
                    strValue = strKey;
        return strValue;
    }
104572
public void init(BaseDatabase database, Record record)
    {
        super.init(database, record);
        if (((QueryRecord)record).getBaseRecord() != null)
            m_tableNext = ((QueryRecord)record).getBaseRecord().getTable();   // Pass most commands thru to the main record's table
    }
996859
def get_collision_handle(self, collision):
        
        if collision not in self._object_handles:
            h = self._get_collision_handle(collision)
            self._object_handles[collision] = h

        return self._object_handles[collision]
660018
public Object getHandle(int iHandleType) throws DBException
    {
        Object bookmark = null;
        try   {
            if ((iHandleType & DBConstants.OBJECT_SOURCE_HANDLE) == 0)
                iHandleType = DBConstants.BOOKMARK_HANDLE;      // For JDBC, always use bookmark
            bookmark = super.getHandle(iHandleType);
        } catch (DBException ex)    {
            throw ex;
        }
        return bookmark;
    }
1189223
def init_db(self):
        
        # get the database url from the configuration
        db_url = self.config.get('database_url', 'sqlite:///nautilus.db')
        # configure the nautilus database to the url
        nautilus.database.init_db(db_url)