Set up the subdomain db's tables
763883
def _create_tables(self):
        
        cursor = self.conn.cursor()

        create_cmd = """CREATE TABLE IF NOT EXISTS {} (
        fully_qualified_subdomain TEXT NOT NULL,
        domain TEXT NOT NULL,
        sequence INTEGER NOT NULL,
        owner TEXT NOT NULL,
        zonefile_hash TEXT NOT NULL,
        signature TEXT NOT NULL,
        block_height INTEGER NOT NULL,
        parent_zonefile_hash TEXT NOT NULL,
        parent_zonefile_index INTEGER NOT NULL,
        zonefile_offset INTEGER NOT NULL,
        txid TEXT NOT NULL,
        missing TEXT NOT NULL,
        accepted INTEGER NOT NULL,
        resolver TEXT,
        PRIMARY KEY(fully_qualified_subdomain,parent_zonefile_index));
        """.format(self.subdomain_table)
        db_query_execute(cursor, create_cmd, ())

        # set up a queue as well
        queue_con = queuedb_open(self.queue_path)
        queue_con.close()
35148
def setup(self):
        """"""
        # get all routes from submodules
        for prefix, routes in self.sub_rt:
            routes.prefix = self.prefix + prefix
            routes.setup()

            fn_name_prefixes = {}
            for fn_key, fn in routes.fn_namespace.items():
                self.fn_namespace[routes.name + '.' + fn_key] = fn
                fn_prefix = routes.name
                if '.' in fn_key:
                    fn_prefix += '.' + fn_key.rsplit('.', 1)[0]
                fn_name_prefixes[fn] = fn_prefix

            for key in self:
                funcs = set(rule[1] for rule in self[key])
                for route, route_module, module, fn in routes.get(key, []):
                    if fn not in funcs:
                        new_route = Route(prefix + route.path)
                        fn.rw_route = new_route
                        fn_name_prefix = fn_name_prefixes[fn]
                        data = (new_route, fn_name_prefix, module, fn)
                        self[key].append(data)

        # sort all rules
        for key in self:
            self[key].sort(key=lambda rule: rule[0])
1270420
def setup_db(session, botconfig, confdir):
    """"""
    Base.metadata.create_all(session.connection())
    # If we're creating a fresh db, we don't need to worry about migrations.
    if not session.get_bind().has_table('alembic_version'):
        conf_obj = config.Config()
        conf_obj.set_main_option('bot_config_path', confdir)
        with resources.path('cslbot', botconfig['alembic']['script_location']) as script_location:
            conf_obj.set_main_option('script_location', str(script_location))
            command.stamp(conf_obj, 'head')

    # Populate permissions table with owner.
    owner_nick = botconfig['auth']['owner']
    if not session.query(Permissions).filter(Permissions.nick == owner_nick).count():
        session.add(Permissions(nick=owner_nick, role='owner'))
305338
Table DOMAINS() {

        Table t = sysTables[DOMAINS];

        if (t == null) {
            t = createBlankTable(sysTableHsqlNames[DOMAINS]);

            addColumn(t, "DOMAIN_CATALOG", SQL_IDENTIFIER);
            addColumn(t, "DOMAIN_SCHEMA", SQL_IDENTIFIER);
            addColumn(t, "DOMAIN_NAME", SQL_IDENTIFIER);
            addColumn(t, "DATA_TYPE", SQL_IDENTIFIER);
            addColumn(t, "CHARACTER_MAXIMUM_LENGTH", CARDINAL_NUMBER);
            addColumn(t, "CHARACTER_OCTET_LENGTH", CARDINAL_NUMBER);
            addColumn(t, "CHARACTER_SET_CATALOG", SQL_IDENTIFIER);
            addColumn(t, "CHARACTER_SET_SCHEMA", SQL_IDENTIFIER);
            addColumn(t, "CHARACTER_SET_NAME", SQL_IDENTIFIER);
            addColumn(t, "COLLATION_CATALOG", SQL_IDENTIFIER);
            addColumn(t, "COLLATION_SCHEMA", SQL_IDENTIFIER);
            addColumn(t, "COLLATION_NAME", SQL_IDENTIFIER);
            addColumn(t, "NUMERIC_PRECISION", CARDINAL_NUMBER);
            addColumn(t, "NUMERIC_PRECISION_RADIX", CARDINAL_NUMBER);
            addColumn(t, "NUMERIC_SCALE", CARDINAL_NUMBER);
            addColumn(t, "DATETIME_PRECISION", CARDINAL_NUMBER);
            addColumn(t, "INTERVAL_TYPE", CHARACTER_DATA);
            addColumn(t, "INTERVAL_PRECISION", CARDINAL_NUMBER);
            addColumn(t, "DOMAIN_DEFAULT", CHARACTER_DATA);
            addColumn(t, "MAXIMUM_CARDINALITY", SQL_IDENTIFIER);
            addColumn(t, "DTD_IDENTIFIER", SQL_IDENTIFIER);
            addColumn(t, "DECLARED_DATA_TYPE", CHARACTER_DATA);
            addColumn(t, "DECLARED_NUMERIC_PRECISION", CARDINAL_NUMBER);
            addColumn(t, "DECLARED_NUMERIC_SCLAE", CARDINAL_NUMBER);

            HsqlName name = HsqlNameManager.newInfoSchemaObjectName(
                sysTableHsqlNames[DOMAINS].name, false, SchemaObject.INDEX);

            t.createPrimaryKey(name, new int[] {
                0, 1, 2, 4, 5, 6
            }, false);

            return t;
        }

        final int domain_catalog             = 0;
        final int domain_schema              = 1;
        final int domain_name                = 2;
        final int data_type                  = 3;
        final int character_maximum_length   = 4;
        final int character_octet_length     = 5;
        final int character_set_catalog      = 6;
        final int character_set_schema       = 7;
        final int character_set_name         = 8;
        final int collation_catalog          = 9;
        final int collation_schema           = 10;
        final int collation_name             = 11;
        final int numeric_precision          = 12;
        final int numeric_precision_radix    = 13;
        final int numeric_scale              = 14;
        final int datetime_precision         = 15;
        final int interval_type              = 16;
        final int interval_precision         = 17;
        final int domain_default             = 18;
        final int maximum_cardinality        = 19;
        final int dtd_identifier             = 20;
        final int declared_data_type         = 21;
        final int declared_numeric_precision = 22;
        final int declared_numeric_scale     = 23;

        //
        PersistentStore store = database.persistentStoreCollection.getStore(t);

        //
        Iterator it =
            database.schemaManager.databaseObjectIterator(SchemaObject.DOMAIN);

        while (it.hasNext()) {
            Type domain = (Type) it.next();

            if (!domain.isDomainType()) {
                continue;
            }

            if (!session.getGrantee().isAccessible(domain)) {
                continue;
            }

            Object[] data = t.getEmptyRowData();

            data[domain_catalog] = database.getCatalogName().name;
            data[domain_schema]  = domain.getSchemaName().name;
            data[domain_name]    = domain.getName().name;
            data[data_type]      = domain.getFullNameString();

            if (domain.isCharacterType()) {
                data[character_maximum_length] =
                    ValuePool.getLong(domain.precision);
                data[character_octet_length] =
                    ValuePool.getLong(domain.precision * 2);
                data[character_set_catalog] = database.getCatalogName().name;
                data[character_set_schema] =
                    ((CharacterType) domain).getCharacterSet().getSchemaName()
                        .name;
                data[character_set_name] =
                    ((CharacterType) domain).getCharacterSet().getName().name;
                data[collation_catalog] = database.getCatalogName().name;
                data[collation_schema] =
                    ((CharacterType) domain).getCollation().getSchemaName()
                        .name;
                data[collation_name] =
                    ((CharacterType) domain).getCollation().getName().name;
            } else if (domain.isNumberType()) {
                data[numeric_precision] =
                    ValuePool.getLong(((NumberType) domain).getPrecision());
                data[declared_numeric_precision] = data[numeric_precision];

                if (domain.typeCode != Types.SQL_DOUBLE) {
                    data[numeric_scale] = ValuePool.getLong(domain.scale);
                    data[declared_numeric_scale] = data[numeric_scale];
                }

                data[numeric_precision_radix] = ValuePool.getLong(
                    ((NumberType) domain).getPrecisionRadix());
            } else if (domain.isBooleanType()) {}
            else if (domain.isDateTimeType()) {
                data[datetime_precision] = ValuePool.getLong(domain.scale);
            } else if (domain.isIntervalType()) {
                data[interval_precision] = ValuePool.getLong(domain.precision);
                data[interval_type]      = domain.getFullNameString();
                data[datetime_precision] = ValuePool.getLong(domain.scale);
            } else if (domain.isBinaryType()) {
                data[character_maximum_length] =
                    ValuePool.getLong(domain.precision);
                data[character_octet_length] =
                    ValuePool.getLong(domain.precision);
            } else if (domain.isBitType()) {
                data[character_maximum_length] =
                    ValuePool.getLong(domain.precision);
                data[character_octet_length] =
                    ValuePool.getLong(domain.precision);
            }

            Expression defaultExpression =
                domain.userTypeModifier.getDefaultClause();

            if (defaultExpression != null) {
                data[domain_default] = defaultExpression.getSQL();
            }

            t.insertSys(store, data);
        }

        return t;
    }
897563
def build_db_tables(db):
    
    
    if not isinstance(db, DAL) or not db._uri:
        raise Exception("Need valid DAL object to define tables")

    # event log - self-explanatory, logs all events
    db.define_table('event_log',
                    Field('event_type'),
                    Field('event_time', 'datetime'),
                    Field('source'),
                    Field('target'),
                    Field('message', 'text'),
                    Field('host'),
                    Field('params', 'list:string'),
                    )
    db.define_table('modules',
                    Field('name', notnull=True, unique=True, length=256),
                    Field('enabled', 'boolean'),
                    Field('event_types', 'list:string'),
                    Field('description', 'text'),
                    Field('echannels', 'list:string'),
                    Field('dchannels', 'list:string'),
                    Field('enicks', 'list:string'),
                    Field('dnicks', 'list:string'),
                    Field('whitelist', 'list:string'),
                    Field('blacklist', 'list:string'),
                    Field('cmd_prefix', length=1, default='!', notnull=True),
                    Field('acl', 'json'),
                    Field('rate_limit', 'json'),
                    )
227521
public function setServerDb ($servers)
		{
			$this->servers = [
				[
					'port' => Yii::$app->settings->get($servers[ 'port' ]),
					'host' => Yii::$app->settings->get($servers[ 'host' ]),
				]
			];
		}
997174
protected function registerTables()
    {
        $tables = $this->container->make('config')->get('swoole.tables', []);

        foreach ($tables as $key => $value) {
            $table   = new SwooleTable($value['size']);
            $columns = $value['columns'] ?? [];
            foreach ($columns as $column) {
                if (isset($column['size'])) {
                    $table->column($column['name'], $column['type'], $column['size']);
                } else {
                    $table->column($column['name'], $column['type']);
                }
            }
            $table->create();

            $this->currentTable->add($key, $table);
        }
    }
466755
public void setSubDomains(java.util.Collection<SubDomain> subDomains) {
        if (subDomains == null) {
            this.subDomains = null;
            return;
        }

        this.subDomains = new java.util.ArrayList<SubDomain>(subDomains);
    }
908312
def set_up(self, u, engine):
        """"""
        def connect_listener_enable_fk(connection, record):
            # fk must be enabled for all connections
            if not getattr(engine, "fk_disabled", False):
                return  # http://trac.buildbot.net/ticket/3490#ticket
                # connection.execute('pragma foreign_keys=ON')

        sa.event.listen(engine.pool, 'connect', connect_listener_enable_fk)
        # try to enable WAL logging
        if u.database:
            def connect_listener(connection, record):
                connection.execute("pragma checkpoint_fullfsync = off")

            sa.event.listen(engine.pool, 'connect', connect_listener)

            log.msg("setting database journal mode to 'wal'")
            try:
                engine.execute("pragma journal_mode = wal")
            except Exception:
                log.msg("failed to set journal mode - database may fail")
1125165
function init()
    {
        $this->_a['table'] = 'cms_terms';
        $this->_a['cols'] = array(
            // ID
            'id' => array(
                'type' => 'Pluf_DB_Field_Sequence',
                'blank' => false,
                'verbose' => 'first name',
                'help_text' => 'id',
                'editable' => false
            ),
            // Fields
            'name' => array(
                'type' => 'Pluf_DB_Field_Varchar',
                'is_null' => false,
                'size' => 200,
                'default' => '',
                'editable' => true
            ),
            'slug' => array(
                'type' => 'Pluf_DB_Field_Varchar',
                'is_null' => false,
                'size' => 200,
                'default' => '',
                'editable' => true
            ),
            /*
             * Foreign keys
             */
        );
    }
1085738
protected function addAdditionTables() : void
    {
        $dbms = strtoupper($this->db->getDBDriver());
        foreach (\constant("static::{$dbms}_ADDITIONAL_TABLES") as $table) {
            $this->tables[]['table_name'] = $table;
        }
    }
763338
def db_tables(name, **connection_args):
    '''
    
    '''
    if not db_exists(name, **connection_args):
        log.info('Database \'%s\' does not exist', name)
        return False

    dbc = _connect(**connection_args)
    if dbc is None:
        return []
    cur = dbc.cursor()
    s_name = quote_identifier(name)
    # identifiers cannot be used as values
    qry = 'SHOW TABLES IN {0}'.format(s_name)
    try:
        _execute(cur, qry)
    except MySQLdb.OperationalError as exc:
        err = 'MySQL Error {0}: {1}'.format(*exc.args)
        __context__['mysql.error'] = err
        log.error(err)
        return []

    ret = []
    results = cur.fetchall()
    for table in results:
        ret.append(table[0])
    log.debug(ret)
    return ret
378766
protected function setupMigrations()
    {
        $migrations = realpath(__DIR__.'/../database/migrations');

        $this->publishes([
            $migrations    => $this->app->databasePath() . '/migrations',
        ]);
    }
985043
def set_allowed_domains(self, allowed_domains):
        """"""
        if allowed_domains is not None:
            allowed_domains = tuple(allowed_domains)
        self._allowed_domains = allowed_domains
589647
def create(self):
        """"""
        self.db_attrs = self.consul.create_db(
                self.instance_name,
                self.instance_type,
                self.admin_username,
                self.admin_password,
                db_name=self.db_name,
                storage_size_gb=self.storage_size,
                timeout_s=self.launch_timeout_s,
                )
1291796
async def setup(self):
        """"""
        try:
            db = await self.db
            collections = await db.list_collection_names()
            created = False
            if self.table_name not in collections:
                # create table
                logger.info("Creating MongoDB collection [{}]".format(self.table_name))
                await db.create_collection(self.table_name)
                await db[self.table_name].create_index([("target_id", DESCENDING), ("post_id", DESCENDING)])
                created = True
            # create control collection if not already created.
            if self.control_table_name and self.control_table_name not in collections:
                # create table
                logger.info("Creating MongoDB control data collection [{}]".format(self.control_table_name))
                await db.create_collection(self.control_table_name)
                created = True
            return created
        except Exception as exc:
            logger.error("[DB] Error when setting up MongoDB collections: {}".format(exc))
        return False
809829
def create_tables(args):
  """"""

  from bob.db.utils import create_engine_try_nolock
  engine = create_engine_try_nolock(args.type, args.files[0], echo=(args.verbose > 2))
  Base.metadata.create_all(engine)