Builds the classes from the database object `db`.
340263
function buildClasses (db) {
  const classes = data.findClasses(db).order('name')

  return classes.map(function (klass) {
    const fns = data
      .findChildFunctions(db, [klass])
      .order('name')
      .map(copyFunction)

    return copyClass(klass, fns)
  })
}
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)
1325677
private function loadDatabases()
	{
		$databaseKeys = $this->config->get('databases:keys')?: [];

		if (!isset($databaseKeys['database'])) $databaseKeys[] = 'database'; // Default database config key

		foreach ($databaseKeys as $databaseKey) {
			$database = $this->config->get($databaseKey);
			if ($database !== false) $this->initConnection($database, $databaseKey);
			$this->config->destroy($databaseKey);
			unset($database);
		}
    }
1173296
def dbclass(self, value):
        

        if not is_valid_dbclass(value):
            raise AttributeError("'{}' is not a valid database type".format(value))

        self._class = value
        self._connectionXML.set('class', value)
216083
def init_db(uri, base, **kwargs):
    
    engine = create_engine(uri, **kwargs)
    base.metadata.create_all(engine)
    return engine
240643
function ( db ) {
          try {
            if ( Array.isArray( options.schemas ) ) {
              options.schemas.forEach(
                function ( schema ) {
                  var keys = Object.keys( schema );

                  db.model( keys[ 0 ], schema[ keys[ 0 ] ] );
                }
              );
            }

            return db;
          } catch ( err ) {
            throw err;
          }
        }
215041
def get_db(cls):
        """"""
        if cls._db:
            return getattr(cls._client, cls._db)
        return cls._client.get_default_database()
940483
protected function loadPClasses()
    {
        try {
            $sth = $this->pdo->prepare(
                "SELECT * FROM `{$this->dbName}`.`{$this->dbTable}`",
                array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY)
            );
            $sth->execute();

            while ($row = $sth->fetch(PDO::FETCH_ASSOC, PDO::FETCH_ORI_NEXT)) {
                $this->addPClass(new KlarnaPClass($row));
            }

            $sth->closeCursor();
            $sth = null;
        } catch (PDOException $e) {
            throw new Klarna_DatabaseException(
                'Could not fetch PClasses from database!'
            );
        }
    }
1033330
protected function buildMapperClasses()
    {
        $this->display(' * Build Mapper classes for table "' . $this->config->getDbTable() . '"' . PHP_EOL);

        $this->display('  > build    [  0%]: field...        ' . PHP_EOL);
        $this->buildMapperFields();
        $this->display('  > build    [ 25%]: primary keys... ' . PHP_EOL);
        $this->buildMapperPrimaryKeys();
        $this->display('  > build    [ 50%]: cache...        ' . PHP_EOL);
        $this->buildMapperCache();
        $this->display('  > build    [100%]: done !          ' . PHP_EOL);
        $this->display(PHP_EOL);
    }
715329
def build_class(name, basenames=(), doc=None):
    """"""
    node = nodes.ClassDef(name, doc)
    for base in basenames:
        basenode = nodes.Name()
        basenode.name = base
        node.bases.append(basenode)
        basenode.parent = node
    return node
658418
def from_file(cls, db_file=ALL_SETS_PATH):
        
        if callable(getattr(db_file, 'read', None)):
            return cls(json.load(db_file))

        with io.open(db_file, encoding='utf8') as inp:
            return cls(json.load(inp))
1213952
def init_db(self, app, entry_point_group='invenio_db.models', **kwargs):
        """"""
        # Setup SQLAlchemy
        app.config.setdefault(
            'SQLALCHEMY_DATABASE_URI',
            'sqlite:///' + os.path.join(app.instance_path, app.name + '.db')
        )
        app.config.setdefault('SQLALCHEMY_ECHO', False)

        # 
        database = kwargs.get('db', db)
        database.init_app(app)

        # Initialize versioning support.
        self.init_versioning(app, database, kwargs.get('versioning_manager'))

        # Initialize model bases
        if entry_point_group:
            for base_entry in pkg_resources.iter_entry_points(
                    entry_point_group):
                base_entry.load()

        # All models should be loaded by now.
        sa.orm.configure_mappers()
        # Ensure that versioning classes have been built.
        if app.config['DB_VERSIONING']:
            manager = self.versioning_manager
            if manager.pending_classes:
                if not versioning_models_registered(manager, database.Model):
                    manager.builder.configure_versioned_classes()
            elif 'transaction' not in database.metadata.tables:
                manager.declarative_base = database.Model
                manager.create_transaction_model()
                manager.plugins.after_build_tx_class(manager)
179803
def get_account_db_class(cls) -> Type[BaseAccountDB]:
        
        if cls.account_db_class is None:
            raise AttributeError("No account_db_class set for {0}".format(cls.__name__))
        return cls.account_db_class
160317
function LevelDB () {
  var self = this;

  self.klass = LevelDB;
  self.klass.super_.apply(self, arguments);
}
354563
def database(name, database_id = nil, &block)
      @databases << get_class_from_scope(Database, name)
        .new(self, database_id, &block)
    end
416801
public static function make()
    {
        $class = str_replace(
            'DatabaseManager',
            ucfirst(config('database.default')).'Database',
            self::class
        );

        try {
            return new self(new $class());
        } catch (\Exception $e) {
            return new self(new MysqlDatabase());
        }
    }
1035341
private function constructDatabase($db)
    {
        if (is_null($this->dbClass)) {
            if (is_array($db)) {
                if (array_keys($db) !== range(0, count($db) - 1)) {
                    $this->db = new Databases\AssociativeArray($db);
                } else {
                    $this->db = new Databases\NumericArray($db);
                }
            } elseif ($db instanceof \Illuminate\Support\Collection) {
                $this->db = new Databases\LaravelCollection($db);
            } elseif ($db instanceof \Illuminate\Database\Eloquent\Builder
                || $db instanceof \Illuminate\Database\Eloquent\Relations\Relation) {
                $this->db = new Databases\LaravelEloquent($db);
            } elseif (!is_object($db)) {
                throw new InvalidArgumentException('Database must be an object or array');
            } else {
                $class_name = get_class($db);

                throw new DomainException("Please add database class for handling $class_name objects");
            }
        } else {
            $this->db = new $dbClass($db);
        }
    }