Database definition class. Conglomerates TableDefinitions and SQL actions corresponding to friendly definition calls.
769356
function() {
	var me = {};
	var db = common.config.database;

	me.act = new NobleMachine();

	return _.extend(me, {
		create_table: function(name, definer) {
			var t = new TableDefinition(name, 'create', definer);
			me.act.next(t.act);
		},

		change_table: function(name, definer) {
			var t = new TableDefinition(name, 'alter', definer);
			me.act.next(t.act);
		},

		drop_table: function(name) {
			me.act.next(db.query(" DROP TABLE `" + name + "`;"));
		},

		rename_table: function(name, newname) {
			me.act.next(db.query(" ALTER TABLE `" + name + "` RENAME `" + newname + "`"));
		},
	});
}
1026447
def _reflect_table(self):
        """"""
        with self.db.lock:
            try:
                self._table = SQLATable(self.name,
                                        self.db.metadata,
                                        schema=self.db.schema,
                                        autoload=True)
            except NoSuchTableError:
                pass
789540
function(tablename, context, definer) {
	var me = {};
	var db = common.config.database;

	me.act = new NobleMachine(); // Query subactions are added as states to this.

	var needsTableCreation = (context == 'create');

	function nextQuery(query) {
		me.act.next(db.query(query));
	}

	var definitions = {
		add_column: function(name, type, options) {
			var col = { name: name, type: type };
			_.extend(col, options);
			
			// If we haven't yet made the table, use the first added column as part of the create statement.
			// All following columns are added via ALTER TABLE. This is because a table cannot be created
			// with zero columns.
			if (needsTableCreation) {
				nextQuery("CREATE TABLE `" + tablename + "` ( " + columnToSQL(col) + " ) ENGINE=INNODB;");
				needsTableCreation = false;
			} else {
				nextQuery("ALTER TABLE `" + tablename + "` ADD " + columnToSQL(col) + ";");
			}
		},

		timestamps: function(options) {
			this.column('createdAt', 'datetime', options);
			this.column('updatedAt', 'datetime', options);
		}
	};

	definitions.column = definitions.add_column;
	
	if (context == 'alter') {
		_.extend(definitions, {
			change_column: function(name, type, options) {
				var col = { name: name, type: type };
				_.extend(col, options);

				nextQuery("ALTER TABLE `" + tablename + "` MODIFY " + columnToSQL(col) + ";");
			},

			remove_column: function(name) {
				nextQuery("ALTER TABLE `" + tablename + "` DROP COLUMN `" + name + "`;");
			},

			// There doesn't seem to be a proper RENAME COLUMN statement in MySQL.
			// As such, it is necessary to use CHANGE after extracting the current column definition.
			rename_column: function(name, newname) {
				var act = new NobleMachine(function() {
					act.toNext(db.query("SHOW COLUMNS FROM `" + tablename + "`;"));
				});

				act.next(function(result) {
					var sql = "ALTER TABLE `" + tablename + "` CHANGE `" + name + "` `" + newname + "`";

					result.forEach(function(coldatum) {
						if (coldatum['Field'] == name) {
							sql += " " + coldatum['Type'];
							
							if (coldatum['Null'] == 'NO') {
								sql += " NOT NULL";
							}

							if (coldatum['Key'] == 'PRI') {
								sql += " PRIMARY KEY";
							}

							sql += coldatum['Extra'];

							if (coldatum['Default'] != 'NULL') {
								sql += " DEFAULT " + coldatum['Default'];
							}
						}
					});
					sql += ";";

					act.toNext(db.query(sql));
				});

				me.act.next(act);
			},
		});
	}

	var types = ['primary_key', 'string', 'text', 'integer', 'boolean', 'datetime', 'timestamp']
	types.forEach(function(type) {
		definitions[type] = function() {
			var options = {}; defs = this;

			var args = Array.prototype.slice.call(arguments);

			args.forEach(function(arg) {
				if (typeof arg == "object") {
					_.extend(options, arg);
				} 
			});

			args.forEach(function(arg) {
				if (typeof arg == "string") {
					defs.column(arg, type, options);
				}
			});
		}
	});

	definer(definitions);

	return me;
}
1287933
private ColumnDefinition[] columnDefinitions(ColumnDefinition[] columns, String[] order)
   {
      Map<String, ColumnDefinition> map = makeColumnMap(columns);
      ColumnDefinition[] result = new ColumnDefinition[order.length];
      for (int index = 0; index < order.length; index++)
      {
         result[index] = map.get(order[index]);
      }
      return result;
   }
1309006
def database_describe(object_id, input_params={}, always_retry=True, **kwargs):
    
    return DXHTTPRequest('/%s/describe' % object_id, input_params, always_retry=always_retry, **kwargs)
3630
function(database, field, options)
  {
    applyOptions( this, options, this.getDefaults( database, field, options ) );

    this.database = database;
    this.name = field;
    this.options = options;
    this.initialized = false;
    this.property = this.property || (indexOf( database.fields, this.name ) !== false);
    this.discriminated = !isEmpty( this.discriminators );

    if ( this.discriminated )
    {
      if ( !Polymorphic )
      {
        throw 'Polymorphic feature is required to use the discriminated option.';
      }

      Class.props( this, Polymorphic );
    }

    this.setReferences( database, field, options );
  }
692673
protected void createSQLDaoDefinition(SQLiteDatabaseSchema schema,
			final Map<String, TypeElement> globalBeanElements, final Map<String, TypeElement> globalDaoElements,
			String daoItem) {
		Element daoElement = globalDaoElements.get(daoItem);

		if (daoElement.getKind() != ElementKind.INTERFACE) {
			String msg = String.format("Class %s: only interfaces can be annotated with @%s annotation",
					daoElement.getSimpleName().toString(), BindDao.class.getSimpleName());
			throw (new InvalidKindForAnnotationException(msg));
		}

		M2MEntity entity = M2MEntity.extractEntityManagedByDAO((TypeElement) daoElement);

		// add to current schema generated entities too
		for (GeneratedTypeElement genItem : this.generatedEntities) {
			if (genItem.getQualifiedName().equals(entity.getQualifiedName())) {
				schema.generatedEntities.add(genItem);
			}
		}

		boolean generated = daoElement.getAnnotation(BindGeneratedDao.class) != null;

		final SQLiteDaoDefinition currentDaoDefinition = new SQLiteDaoDefinition(schema, daoItem,
				(TypeElement) daoElement, entity.getClassName().toString(), generated);

		// content provider management
		BindContentProviderPath daoContentProviderPath = daoElement.getAnnotation(BindContentProviderPath.class);
		if (daoContentProviderPath != null) {
			currentDaoDefinition.contentProviderEnabled = true;
			currentDaoDefinition.contentProviderPath = daoContentProviderPath.path();
			currentDaoDefinition.contentProviderTypeName = daoContentProviderPath.typeName();

			if (StringUtils.isEmpty(currentDaoDefinition.contentProviderTypeName)) {
				Converter<String, String> convert = CaseFormat.UPPER_CAMEL.converterTo(CaseFormat.LOWER_UNDERSCORE);
				AssertKripton.assertTrue(currentDaoDefinition.getParent().contentProvider != null,
						"DAO '%s' has an inconsistent content provider definition, perhaps you forget to use @%s in data source interface?",
						currentDaoDefinition.getElement().getQualifiedName(),
						BindContentProvider.class.getSimpleName());
				currentDaoDefinition.contentProviderTypeName = currentDaoDefinition
						.getParent().contentProvider.authority + "."
						+ convert.convert(currentDaoDefinition.getSimpleEntityClassName());
			}
		}

		// dao is associated to an entity is not contained in analyzed class
		// set.
		if (!globalBeanElements.containsKey(currentDaoDefinition.getEntityClassName())
				&& !isGeneratedEntity(currentDaoDefinition.getEntityClassName())) {
			throw (new InvalidBeanTypeException(currentDaoDefinition));
		}

		schema.add(currentDaoDefinition);

		fillMethods(currentDaoDefinition, daoElement);

		// get @annotation associated to many 2 many relationship
		BindDaoMany2Many daoMany2Many = daoElement.getAnnotation(BindDaoMany2Many.class);

		// dao definition must have >0 method associated to query
		if (currentDaoDefinition.getCollection().size() == 0 && daoMany2Many == null) {
			throw (new DaoDefinitionWithoutAnnotatedMethodException(currentDaoDefinition));
		}
	}
1029760
function getTableDefinition(tableDefinitions, tableName) {
    Validate.isObject(tableDefinitions);
    Validate.notNull(tableDefinitions);
    Validate.isString(tableName);
    Validate.notNullOrEmpty(tableName);

    return tableDefinitions[tableName.toLowerCase()];
}
738495
def build_definitions(dpath="sqlalchemy_models/_definitions.json"):
    
    command.run(AlsoChildrenWalker, module=todo, outdir="sqlalchemy_models", definition_name="_definitions.json",
                relation_decision=RelationDesicion())
    pass  # skip due to unpatched issue in alchemyjsonschema run()
    definitions = ""
    for line in open(dpath, 'r'):
        definitions += line
    definitions = json.loads(definitions)
    newdef = open(dpath.replace("_def", "def"), 'w+')
    for name in definitions['definitions']:
        for mod in [um, em, wm, bm]:
            if hasattr(mod, name):
                model = getattr(mod, name)
                for attr in definitions['definitions'][name]['properties']:
                    if hasattr(getattr(model, attr).property, 'columns') and \
                            isinstance(getattr(model, attr).property.columns[0].type, LedgerAmount):
                        definitions['definitions'][name]['properties'][attr]['type'] = "number"
    newdef.write(json.dumps(definitions, indent=2))
    newdef.close()
1302222
private void processDatabaseTableCollection(final Object databaseTableCollection) {
        if (databaseTableCollection == null || !isCastable("java.util.Collection", databaseTableCollection.getClass())) {
            return;
        }

        final Collection<?> c = (Collection<?>) databaseTableCollection;
        for (Object descriptor : c) {
            processDatabaseTableObject(descriptor);
        }
    }
642435
def column(name, definition)
      @column ||= if definition.is_a?(Symbol)
                    ColumnWithType.new(name, definition)
                  else
                    ColumnWithSql.new(name, definition)
                  end
    end
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]
283037
def describe(table_name, region=None, key=None, keyid=None, profile=None):
    '''
    
    '''
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
    table = Table(table_name, connection=conn)
    return table.describe()
378618
public void setTDBTClassDefinition(String tdbtClass, Identification id, Attributes attr) {
	this.tdbtCD = ClassDefinitionImpl.toClassDefinition(tdbtClass, id, attr);
	this.tdbt = null;
    }
28595
public Set<String> getDatabaseIds(OWLClass entity) {
    Set<String> dbAnnotations = new HashSet<>();
    for (OWLAnnotation annotation : entity.getAnnotations(ontology)) {
      if (annotation.getValue() instanceof OWLLiteral) {
        OWLLiteral val = (OWLLiteral) annotation.getValue();
        String value = val.getLiteral();
        if (value.matches(DB_ID_PATTERN)) {
          dbAnnotations.add(value);
        }
      }
    }
    return dbAnnotations;
  }
35034
private HTableDescriptor getTableDescriptor(Class<?> clazz, EntityType<?> entityType, String tableName)
    {
        try
        {
            AbstractManagedType<?> ent = (AbstractManagedType<?>) entityType;
            HTableDescriptor tableDescriptor = null;
            String hTableName = HBaseUtils.getHTableName(databaseName, tableName);
            tableDescriptor = !admin.tableExists(TableName.valueOf(hTableName)) ? new HTableDescriptor(
                    TableName.valueOf(hTableName)) : admin.getTableDescriptor(TableName.valueOf(hTableName));
            addColumnFamilyAndSetProperties(tableDescriptor, tableName);

            // Add column families for @SecondaryTable
            List<String> secondaryTables = ((DefaultEntityAnnotationProcessor) ent.getEntityAnnotation())
                    .getSecondaryTablesName();
            for (String secTable : secondaryTables)
            {
                addColumnFamilyAndSetProperties(tableDescriptor, secTable);
            }

            // handle @JoinTable for @ManyToMany
            List<Relation> relations = KunderaMetadataManager.getEntityMetadata(kunderaMetadata, clazz).getRelations();
            addJoinTable(relations);

            // @CollectionTable is not handled.
            return tableDescriptor;
        }
        catch (IOException ex)
        {
            logger.error("Either table isn't in enabled state or some network problem, Caused by: ", ex);
            throw new SchemaGenerationException(ex, "Hbase");
        }
    }
1045795
private static <T, ID> void addCreateTableStatements(DatabaseType databaseType, TableInfo<T, ID> tableInfo,
			List<String> statements, List<String> queriesAfter, boolean ifNotExists, boolean logDetails)
			throws SQLException {
		StringBuilder sb = new StringBuilder(256);
		if (logDetails) {
			logger.info("creating table '{}'", tableInfo.getTableName());
		}
		sb.append("CREATE TABLE ");
		if (ifNotExists && databaseType.isCreateIfNotExistsSupported()) {
			sb.append("IF NOT EXISTS ");
		}
		databaseType.appendEscapedEntityName(sb, tableInfo.getTableName());
		sb.append(" (");
		List<String> additionalArgs = new ArrayList<String>();
		List<String> statementsBefore = new ArrayList<String>();
		List<String> statementsAfter = new ArrayList<String>();
		// our statement will be set here later
		boolean first = true;
		for (FieldType fieldType : tableInfo.getFieldTypes()) {
			// skip foreign collections
			if (fieldType.isForeignCollection()) {
				continue;
			} else if (first) {
				first = false;
			} else {
				sb.append(", ");
			}
			String columnDefinition = fieldType.getColumnDefinition();
			if (columnDefinition == null) {
				// we have to call back to the database type for the specific create syntax
				databaseType.appendColumnArg(tableInfo.getTableName(), sb, fieldType, additionalArgs, statementsBefore,
						statementsAfter, queriesAfter);
			} else {
				// hand defined field
				databaseType.appendEscapedEntityName(sb, fieldType.getColumnName());
				sb.append(' ').append(columnDefinition).append(' ');
			}
		}
		// add any sql that sets any primary key fields
		databaseType.addPrimaryKeySql(tableInfo.getFieldTypes(), additionalArgs, statementsBefore, statementsAfter,
				queriesAfter);
		// add any sql that sets any unique fields
		databaseType.addUniqueComboSql(tableInfo.getFieldTypes(), additionalArgs, statementsBefore, statementsAfter,
				queriesAfter);
		for (String arg : additionalArgs) {
			// we will have spat out one argument already so we don't have to do the first dance
			sb.append(", ").append(arg);
		}
		sb.append(") ");
		databaseType.appendCreateTableSuffix(sb);
		statements.addAll(statementsBefore);
		statements.add(sb.toString());
		statements.addAll(statementsAfter);
		addCreateIndexStatements(databaseType, tableInfo, statements, ifNotExists, false, logDetails);
		addCreateIndexStatements(databaseType, tableInfo, statements, ifNotExists, true, logDetails);
	}