Пример #1
0
def michigan_db_to_table_tuples(db):
  """Returns list of abstract_sql.TableSchema from Michigan schema object."""
  table_schemas = list()
  for table_name, columns in db.items():
    table_schemas.append(
        abstract_sql.TableSchema(
            table_name=table_name.lower(),
            column_names=[column['field name'].lower() for column in columns]))
  return table_schemas
Пример #2
0
def wikisql_db_to_table_tuples(db_name, db):
    """Return list of abstract_sql.TableSchema from a dict describing a DB."""
    del db_name
    table_schemas = list()
    for table_name, columns in db.items():
        column_names = [column['field name'].lower() for column in columns]
        table_schemas.append(
            abstract_sql.TableSchema(table_name=table_name.lower(),
                                     column_names=column_names))
    return table_schemas
Пример #3
0
def spider_db_to_table_tuples(db):
    """Return list of abstract_sql.TableSchema from spider json."""
    # The format of the db json object is documented here:
    # https://github.com/taoyds/spider#tables
    # List of string table names.
    table_names = db['table_names_original']
    # List of lists with [table_idx, column_name].
    column_list = db['column_names_original']
    column_names_indexed_by_table = [[] for _ in table_names]
    for column in column_list:
        column_names_indexed_by_table[column[0]].append(column[1].lower())
    table_schemas = []
    for table_name, column_names in zip(table_names,
                                        column_names_indexed_by_table):
        table_schemas.append(
            abstract_sql.TableSchema(
                table_name=table_name.lower(),
                column_names=column_names,
            ))
    return table_schemas