Returns table description
        >>> yql.desc('geo.countries')
        >>>
559027
def desc(self, table):
        '''
        '''
        query = "desc {0}".format(table)
        response = self.raw_query(query)

        return response
1155783
def country_list_nlp(cts):
    """"""
    ct_nlp = []
    for i in cts.keys():
        nlped = nlp(i)
        ct_nlp.append(nlped)
    return ct_nlp
11473
function columnsToSQL(columns, tables) {
  if (!columns) return
  const baseTable = Array.isArray(tables) && tables[0]
  let isDual = false
  if (baseTable && baseTable.type === 'dual') isDual = true
  return columns
    .map(column => {
      const { expr } = column
      if (isDual) expr.isDual = isDual
      let str = exprToSQL(expr)
      if (column.as !== null) {
        str = `${str} AS `
        if (column.as.match(/^[a-z_][0-9a-z_]*$/i)) str = `${str}${identifierToSql(column.as)}`

        else str = `${str}\`${column.as}\``
      }

      return str
    })
    .join(', ')
}
691795
public List<String> listIndexDefinitions(boolean used, List<String> tables)
  {
    String scansOp = used ? "!=" : "=";
    String sql
      = "SELECT pg_get_indexdef(x.indexrelid) AS indexdef "
      + "FROM pg_index x, pg_class c "
      + "WHERE x.indexrelid = c.oid "
      + "AND c.relname IN ( " + StringUtils.repeat("?", ",", tables.size())
      + ") "
      + "AND pg_stat_get_numscans(x.indexrelid) " + scansOp + " 0";
    return getJdbcTemplate().query(sql, tables.toArray(), stringRowMapper());
  }
34934
def coordinates(self, x, y, **kwargs):
        ''''''
        kwargs['returntype'] = 'geographies'
        fields = {
            'x': x,
            'y': y
        }

        return self._fetch('coordinates', fields, **kwargs)
1238972
def get_tables_for_query(query):
    
    from django.db.models.sql.where import WhereNode, SubqueryConstraint
    from django.db.models.query import QuerySet
    tables = set([v[0] for v in getattr(query,'alias_map',{}).values()])

    def get_sub_query_tables(node):
        query = node.query_object
        if not hasattr(query, 'field_names'):
            query = query.values(*node.targets)
        else:
            query = query._clone()
        query = query.query
        return set(v[0] for v in getattr(query, 'alias_map',{}).values())

    def get_tables(node, tables):
        if isinstance(node, SubqueryConstraint):
            return get_sub_query_tables(node)
        for child in node.children:
            if isinstance(child, WhereNode):  # and child.children:
                tables |= set(get_tables(child, tables))
            elif not hasattr(child, '__iter__'):
                continue
            else:
                for item in (c for c in child if isinstance(c, QuerySet)):
                    tables |= get_tables_for_query(item.query)
        return tables

    if query.where and query.where.children:
        where_nodes = [c for c in query.where.children if isinstance(c, (WhereNode, SubqueryConstraint))]
        for node in where_nodes:
            tables |= get_tables(node, tables)

    return list(tables)
622384
def countryccys():
    '''
    
    '''
    global _country_ccys
    if not _country_ccys:
        v = {}
        _country_ccys = v
        ccys = currencydb()
        for c in eurozone:
            v[c] = 'EUR'
        for c in ccys.values():
            if c.default_country:
                v[c.default_country] = c.code
    return _country_ccys
392876
def get_woeid(lat, lon):
    """"""
    yql = _YQL_WOEID.format(lat, lon)

    # send request
    tmpData = _yql_query(yql)

    if tmpData is None:
        _LOGGER.error("No woid is received!")
        return None

    # found woid?
    return tmpData.get("place", {}).get("woeid", None)
654362
def get_table_description(self, cursor, table_name):
        ""
        # As cursor.description does not return reliably the nullable property,
        # we have to query the information_schema (#7783)
        cursor.execute("""
            SELECT column_name, is_nullable, column_default
            FROM information_schema.columns
            WHERE table_schema = %s and table_name = %s""", [self.connection.schema_name, table_name])
        field_map = {line[0]: line[1:] for line in cursor.fetchall()}
        cursor.execute("SELECT * FROM %s LIMIT 1" % self.connection.ops.quote_name(table_name))
        return [FieldInfo(*((force_text(line[0]),) + line[1:6] +
                            (field_map[force_text(line[0])][0] == 'YES', field_map[force_text(line[0])][1])))
                for line in cursor.description]
582674
function getCountryByName(name, useAlias) {
  if (!_.isString(name)) return undefined;

  return _.find(countries, (country) => {
    if (useAlias) {
      return country.name.toUpperCase() === name.toUpperCase()
        ||  _.find(country.alias, (alias) => (alias.toUpperCase() === name.toUpperCase()));
    }
    return country.name.toUpperCase() === name.toUpperCase();
  });
}
1185960
def get_user_tables(conn):
    """"""

    query_string = "select schemaname, relname from pg_stat_user_tables;"
    with conn.cursor() as cursor:
        cursor.execute(query_string)
        tables = cursor.fetchall()

    return tables
735066
def _get_table_as_string(self):
        """"""
        tablelist = []
        tablelist.append("!%s_table_begin" % self.geotype.lower())
        tablelist.append("\t".join(self.table.columns))
        for idx, row in self.table.iterrows():
            tablelist.append("\t".join(map(str, row)))
        tablelist.append("!%s_table_end" % self.geotype.lower())
        return "\n".join(tablelist)
74341
def load_country_map_data():
    """"""
    csv_bytes = get_example_data(
        'birth_france_data_for_country_map.csv', is_gzip=False, make_bytes=True)
    data = pd.read_csv(csv_bytes, encoding='utf-8')
    data['dttm'] = datetime.datetime.now().date()
    data.to_sql(  # pylint: disable=no-member
        'birth_france_by_region',
        db.engine,
        if_exists='replace',
        chunksize=500,
        dtype={
            'DEPT_ID': String(10),
            '2003': BigInteger,
            '2004': BigInteger,
            '2005': BigInteger,
            '2006': BigInteger,
            '2007': BigInteger,
            '2008': BigInteger,
            '2009': BigInteger,
            '2010': BigInteger,
            '2011': BigInteger,
            '2012': BigInteger,
            '2013': BigInteger,
            '2014': BigInteger,
            'dttm': Date(),
        },
        index=False)
    print('Done loading table!')
    print('-' * 80)
    print('Creating table reference')
    obj = db.session.query(TBL).filter_by(table_name='birth_france_by_region').first()
    if not obj:
        obj = TBL(table_name='birth_france_by_region')
    obj.main_dttm_col = 'dttm'
    obj.database = utils.get_or_create_main_db()
    if not any(col.metric_name == 'avg__2004' for col in obj.metrics):
        obj.metrics.append(SqlMetric(
            metric_name='avg__2004',
            expression='AVG(2004)',
        ))
    db.session.merge(obj)
    db.session.commit()
    obj.fetch_metadata()
    tbl = obj

    slice_data = {
        'granularity_sqla': '',
        'since': '',
        'until': '',
        'where': '',
        'viz_type': 'country_map',
        'entity': 'DEPT_ID',
        'metric': {
            'expressionType': 'SIMPLE',
            'column': {
                'type': 'INT',
                'column_name': '2004',
            },
            'aggregate': 'AVG',
            'label': 'Boys',
            'optionName': 'metric_112342',
        },
        'row_limit': 500000,
    }

    print('Creating a slice')
    slc = Slice(
        slice_name='Birth in France by department in 2016',
        viz_type='country_map',
        datasource_type='table',
        datasource_id=tbl.id,
        params=get_slice_json(slice_data),
    )
    misc_dash_slices.add(slc.slice_name)
    merge_slice(slc)
597635
def db_get_map(self, table, record, column):
        
        val = self.db_get_val(table, record, column)
        assert isinstance(val, dict)
        return val
600537
def table_describe(table_name):
    
    desc = orca.get_table(table_name).to_frame().describe()
    return (
        desc.to_json(orient='split', date_format='iso'),
        200,
        {'Content-Type': 'application/json'})
549882
def tables(subjects=None,
           pastDays=None,
           include_inactive=False,
           lang=DEFAULT_LANGUAGE):
    
    request = Request('tables',
                      subjects=subjects,
                      pastDays=pastDays,
                      includeInactive=include_inactive,
                      lang=lang)

    return (Table(table, lang=lang) for table in request.json)
40569
def use(self, url, name='mytable'):
        '''
        '''
        self.yql_table_url = url
        self.yql_table_name = name
        return {'table url': url, 'table name': name}