database is ready for use
501404
function onsuccess(event) {
            // remember the db instance
            self.db = event.target.result;

            // storage is now possible
            self.store = true;

            // execute all pending operations
            while (self.waiting.length) {
                self.waiting.shift().call(self);
            }

            // we're done, fire the callback
            if (cb) {
                cb.call(self, self);
            }
        }
1348890
function( baseDir, database ) {

	// Check for missing baseDir
	if (typeof(baseDir) === "object") {
		database = baseDir;
		baseDir = "";
	}

	// Initialize properties
	this.database = database || {};

	// Keep the base dir
	this.baseDir = baseDir || "";

	// Queued requests pending loading
	this.queuedRequests = [];

	// Keep object table
	this.profile = new DecodeProfile();

	// Progress manager
	this.progressManager = new ProgressManager();

}
83051
def ensure_table(self, cls):
        """"""
        id_len = len(uuid())
        index_names = cls.index_names() or []
        cols = [
            'id char(%d) primary key' % (id_len,),
            'value jsonb'
        ] + [
            name + ' text' for name in index_names
        ]

        table_name = cls.get_table_name()

        with self._conn() as conn:
            with conn.cursor() as cur:
                cur.execute('create table if not exists %s (%s);' % (
                    table_name,
                    ','.join(cols)
                ))
                for name in index_names:
                    cur.execute('create index if not exists %s on %s(%s);' % (
                        table_name + '_' + name + '_idx',
                        table_name,
                        name
                    ))
1283482
def bind(self, database):
        
        self._database = database

        while not self._sessions.full():
            session = self._new_session()
            session.create()
            self._sessions.put(session)
613090
def _setup_db(cls):
        
        uri = cls._app.config.get("DB_URL")
        if uri:
            db.connect__(uri, cls._app)
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());
    }
1346154
def init_database(self):
        """"""
        with contextlib.closing(self.database.cursor()) as cursor:
            cursor.execute("""
              CREATE TABLE IF NOT EXISTS users(
                id INTEGER PRIMARY KEY AUTOINCREMENT,
                name VARCHAR(32)
              )
            """)
595863
function Database(pg) {
  this.pg = pg;
  this.defaults = pg.defaults;
  this.connect = this.connect.bind(this);
  this.end = this.end.bind(this);
}
790713
def init_db(self):
    '''

    '''

    # Database Setup, use default if uri not provided
    if self.database == 'sqlite':
        db_path = os.path.join(EXPFACTORY_DATA, '%s.db' % EXPFACTORY_SUBID)
        self.database = 'sqlite:///%s' % db_path

    bot.info("Database located at %s" % self.database)
    self.engine = create_engine(self.database, convert_unicode=True)
    self.session = scoped_session(sessionmaker(autocommit=False,
                                               autoflush=False,
                                               bind=self.engine))
    
    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
    Base.metadata.create_all(bind=self.engine)
    self.Base = Base
691582
def mysql(host, user, passwd, db, charset):
    """"""
    connection_string = database.set_mysql_connection(host=host, user=user, passwd=passwd, db=db, charset=charset)
    test_connection(connection_string)
484229
def db(context, data):
    """"""
    table = context.params.get("table", context.crawler.name)
    params = context.params
    params["table"] = table
    _recursive_upsert(context, params, data)
1003368
private function configureDatabase ()
    {
        $this->comment ("Database configuration:");

        $db['host']     = $this->choice ("Database hostname: ", ['localhost', 'custom'], 0);
        $db['name']     = $this->ask ("Database name: ");
        $db['username'] = $this->ask ("Database username: ");
        $db['password'] = $this->secret ("Database password: ");

        if (!$this->_connected ($db)) {
            $this->info ('');
            $this->error ('Not connected to database');
            $this->info ('');

            return $this->configureDatabase ();
        }

        $this->envData['DB_HOST']     = $db['host'];
        $this->envData['DB_DATABASE'] = $db['name'];
        $this->envData['DB_USERNAME'] = $db['username'];
        $this->envData['DB_PASSWORD'] = $db['password'] . "\n";

        $this->info ('');
        $this->comment ('Database configured successfully!');
        $this->info ('');
    }
384746
protected function isDatabaseReady()
    {
        // Such as during setup of testsession prior to DB connection.
        if (!DB::is_active()) {
            return false;
        }

        // If we have a DB of the wrong type then complain
        if (!(DB::get_conn() instanceof MySQLDatabase)) {
            throw new Exception('HybridSessions\Store\DatabaseStore currently only works with MySQL databases');
        }

        // Prevent freakout during dev/build
        return ClassInfo::hasTable('HybridSessionDataObject');
    }
240207
def _loadDB(self):
        """"""
        if not self._validID():
            raise NotFound, self._getID()
        (sql, fields) = self._prepareSQL("SELECT")
        curs = self.cursor()
        curs.execute(sql, self._getID())
        result = curs.fetchone()
        if not result:
            curs.close()
            raise NotFound, self._getID()
        self._loadFromRow(result, fields, curs)
        curs.close()
        self._updated = time.time()
578260
def ready(self):
        
        cmd = self._psql_cmd()
        for i in range(50, -1, -1):
            res = subprocess.call(
                cmd, stdin=DEV_NULL, stdout=DEV_NULL,
                stderr=DEV_NULL)
            if res == 0:
                break
            time.sleep(0.2)
        return i != 0
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;
    }
1201436
def initdb():
    """"""
    from plnt.database import Blog, session

    make_app().init_database()
    # and now fill in some python blogs everybody should read (shamelessly
    # added my own blog too)
    blogs = [
        Blog(
            "Armin Ronacher",
            "http://lucumr.pocoo.org/",
            "http://lucumr.pocoo.org/cogitations/feed/",
        ),
        Blog(
            "Georg Brandl",
            "http://pyside.blogspot.com/",
            "http://pyside.blogspot.com/feeds/posts/default",
        ),
        Blog(
            "Ian Bicking",
            "http://blog.ianbicking.org/",
            "http://blog.ianbicking.org/feed/",
        ),
        Blog(
            "Amir Salihefendic", "http://amix.dk/", "http://feeds.feedburner.com/amixdk"
        ),
        Blog(
            "Christopher Lenz",
            "http://www.cmlenz.net/blog/",
            "http://www.cmlenz.net/blog/atom.xml",
        ),
        Blog(
            "Frederick Lundh",
            "http://online.effbot.org/",
            "http://online.effbot.org/rss.xml",
        ),
    ]
    # okay. got tired here.  if someone feels that he is missing, drop me
    # a line ;-)
    for blog in blogs:
        session.add(blog)
    session.commit()
    click.echo("Initialized database, now run manage-plnt.py sync to get the posts")