See db.Database.
558190
def WriteSignedBinaryReferences(self, binary_id,
                                  references):
    """"""
    self.signed_binary_references[_SignedBinaryKeyFromID(binary_id)] = (
        references.Copy(), rdfvalue.RDFDatetime.Now())
550394
def db(self):
        
        if self.database is NotImplemented:
            self.database = Session

        return self.database
718360
def sql(self):
        """"""
        from fasta.indexed import DatabaseFASTA, fasta_to_sql
        db = DatabaseFASTA(self.prefix_path + ".db")
        if not db.exists: fasta_to_sql(self.path, db.path)
        return db
725762
def init():
    """"""
    click.secho('Creating database {0}'.format(_db.engine.url),
                fg='green')
    if not database_exists(str(_db.engine.url)):
        create_database(str(_db.engine.url))
730433
def create_db_info():
        """"""
        result = {}
        result['instrument'] = ''
        result['uuid'] = ''
        result['tags'] = {}
        result['type'] = ''
        result['mode'] = ''
        result['observation_date'] = ""
        result['origin'] = {}
        return result
1116353
def db(cls, dbname=None):
        

        cls._load_entry_points()

        dbname = dbname or config.get('eop', 'dbname', fallback=cls.DEFAULT_DBNAME)

        if dbname not in cls._dbs.keys():
            raise EopError("Unknown database '%s'" % dbname)

        if isclass(cls._dbs[dbname]):
            # Instanciation
            try:
                cls._dbs[dbname] = cls._dbs[dbname]()
            except Exception as e:
                # Keep the exception in cache in order to not retry instanciation
                # every single time EopDb.db() is called, as instanciation
                # of database is generally a time consumming operation.
                # If it failed once, it will most probably fail again
                cls._dbs[dbname] = e

        if isinstance(cls._dbs[dbname], Exception):
            raise EopError("Problem at database instanciation") from cls._dbs[dbname]

        return cls._dbs[dbname]
1320870
def present(name, containment='NONE', options=None, **kwargs):
    '''
    
    '''
    ret = {'name': name,
           'changes': {},
           'result': True,
           'comment': ''}

    if __salt__['mssql.db_exists'](name, **kwargs):
        ret['comment'] = 'Database {0} is already present (Not going to try to set its options)'.format(name)
        return ret
    if __opts__['test']:
        ret['result'] = None
        ret['comment'] = 'Database {0} is set to be added'.format(name)
        return ret

    db_created = __salt__['mssql.db_create'](name, containment=containment, new_database_options=_normalize_options(options), **kwargs)
    if db_created is not True:  # Non-empty strings are also evaluated to True, so we cannot use if not db_created:
        ret['result'] = False
        ret['comment'] += 'Database {0} failed to be created: {1}'.format(name, db_created)
        return ret
    ret['comment'] += 'Database {0} has been added'.format(name)
    ret['changes'][name] = 'Present'
    return ret
1120745
def _parse_db_lib(cls, library):
        
        database_name = library.split('.', 2)
        if len(database_name) == 2:
            library = database_name[1]
            if database_name[0].startswith(cls.DB_PREFIX):
                database_name = database_name[0]
            else:
                database_name = cls.DB_PREFIX + '_' + database_name[0]
        else:
            database_name = cls.DB_PREFIX
        return database_name, library
563822
function DBMonView() {
	return (vm, dbs) =>
		el("div", [
			el("table.table.table-striped.latest-data", [
				el("tbody", dbs.map(db =>
					vw(DB, db)
				))
			])
		])
}
123711
def reflect_db(self):
        
        self.metadata.reflect(views=True, extend_existing=True)
        self.base = automap_base(metadata=self.metadata)
        self.base.prepare()
1322923
def load(dbname, dbmode='a'):
    
    if dbmode == 'w':
        raise AttributeError("dbmode='w' not allowed for load.")
    db = Database(dbname, dbmode=dbmode)

    return db
197674
def initdb(self):
        """"""
        if hasattr(self, 'alchemist'):
            self.alchemist.meta.create_all(self.engine)
            if 'branch' not in self.globl:
                self.globl['branch'] = 'trunk'
            if 'rev' not in self.globl:
                self.globl['rev'] = 0
            return
        from sqlite3 import OperationalError
        cursor = self.connection.cursor()
        try:
            cursor.execute('SELECT * FROM global;')
        except OperationalError:
            cursor.execute(self.strings['create_global'])
        if 'branch' not in self.globl:
            self.globl['branch'] = 'trunk'
        if 'turn' not in self.globl:
            self.globl['turn'] = 0
        if 'tick' not in self.globl:
            self.globl['tick'] = 0
        for table in (
            'branches',
            'turns',
            'graphs',
            'graph_val',
            'nodes',
            'node_val',
            'edges',
            'edge_val',
            'plans',
            'plan_ticks'
        ):
            try:
                cursor.execute('SELECT * FROM ' + table + ';')
            except OperationalError:
                cursor.execute(self.strings['create_' + table])
942742
function (database, callback) {
        var s = this,
            querier = s._querier;
        querier.connect();
        async.waterfall([
            function (callback) {
                querier.showTables(database, function (err, tables) {
                    callback(err, tables);
                });
            },
            function (tables, callback) {
                var tableNames = s._parseTableNames(tables);
                async.map(tableNames, function (table, callback) {
                    querier.descTable(database, table, function (err, data1) {
                        querier.selectKeyColumnUsage(database, table, function (err, data2) {
                            callback(err, {
                                name: table,
                                columns: s._parseTableData(data1),
                                relations: s._getRelations(data2, table)
                            });
                        });
                    });
                }, callback);
            },
            function (data, callback) {
                var database = {};
                data.forEach(function (data) {
                    database[data.name] = data;
                });
                callback(null, database);
            }
        ], function (err, result) {
            querier.disconnect();
            callback(err, result);
        });
        return s;
    }
1138546
def _compare_dbs_getter(self, db):
        """"""
        # Change DB connection if needed
        if self.database != db:
            self.change_db(db)
        return self.count_rows_all()
191396
def open( self ):
        """"""
        if self._connection is None:
            self._connection = sqlite3.connect(self._dbfile)
1265193
@SuppressWarnings("unchecked")
	private static void readDB(String dbName) {
        PersistenceManager pm = ZooJdoHelper.openDB(dbName);
        pm.currentTransaction().begin();

        //Extents are one way to get objects from a database:
        System.out.println("Person extent: ");
        Extent<Person> ext = pm.getExtent(Person.class);
        for (Person p: ext) {
            System.out.println("Person found: " + p.getName());
        }
        ext.closeAll();
        
        //Queries are more powerful:
        System.out.println("Queries: ");
        Query query = pm.newQuery(Person.class, "name == 'Bart'");
        Collection<Person> barts = (Collection<Person>) query.execute();
        for (Person p: barts) {
            System.out.println("Person found called 'Bart': " + p.getName());
        }
        query.closeAll();
        
        //Once an object is loaded, normal method calls can be used to traverse the object graph.
        Person bart = barts.iterator().next();
        System.out.println(bart.getName() + " has " + bart.getFriends().size() + " friend(s):");
        for (Person p: bart.getFriends()) {
            System.out.println(p.getName() + " is a friend of " + bart.getName());
        }
        
        
        pm.currentTransaction().commit();
        closeDB(pm);
    }
169790
def _db(self):
        
        if not hasattr(self, "_db_client") or getattr(self, "_db_client") is None:
            self._db_client = get_db_client()
        return self._db_client