Parameters:
     - db_name
     - tbl_name
     - col_name
338504
def get_table_column_statistics(self, db_name, tbl_name, col_name):
    
    self.send_get_table_column_statistics(db_name, tbl_name, col_name)
    return self.recv_get_table_column_statistics()
495931
def list_database_names(self, session=None):
        
        return [doc["name"]
                for doc in self.list_databases(session, nameOnly=True)]
663414
def alter_db(name, character_set=None, collate=None, **connection_args):
    '''
    
    '''
    dbc = _connect(**connection_args)
    if dbc is None:
        return []
    cur = dbc.cursor()
    existing = db_get(name, **connection_args)
    qry = 'ALTER DATABASE `{0}` CHARACTER SET {1} COLLATE {2};'.format(
        name.replace('%', r'\%').replace('_', r'\_'),
        character_set or existing.get('character_set'),
        collate or existing.get('collate'))
    args = {}
    _execute(cur, qry, args)
1105948
def validate_table_name(name):
    

    try:
        validate_sqlite_table_name(name)
    except (InvalidCharError, InvalidReservedNameError) as e:
        raise NameValidationError(e)
    except NullNameError:
        raise NameValidationError("table name is empty")
    except ValidReservedNameError:
        pass
174916
def get_partition_names_ps(self, db_name, tbl_name, part_vals, max_parts):
    
    self.send_get_partition_names_ps(db_name, tbl_name, part_vals, max_parts)
    return self.recv_get_partition_names_ps()
270747
def get_table_columns(dbconn, tablename):
    
    cur = dbconn.cursor()
    cur.execute("PRAGMA table_info('%s');" % tablename)
    info = cur.fetchall()
    cols = [(i[1], i[2]) for i in info]
    return cols
698153
public function whichDB($db_name)
    {
        if ($this->connection->tableExists($db_name . $this->connection->sep() . $this->name)) {
            $this->fq_name = $db_name . $this->connection->sep() . $this->name;
            return true;
        } else {
            return false;
        }
    }
1327966
def db_exists(name, **client_args):
    '''
    
    '''
    if name in [db['name'] for db in list_dbs(**client_args)]:
        return True

    return False
862637
private String dbProp(String name) {

        String dbType = m_setupBean.getDatabase();
        Object prop = m_setupBean.getDatabaseProperties().get(dbType).get(dbType + "." + name);
        if (prop == null) {
            return "";
        }
        return prop.toString();
    }
342018
def get_table(self, dbname, tbl_name):
    
    self.send_get_table(dbname, tbl_name)
    return self.recv_get_table()
434125
def create_CTL(fname, tbl_name, col_list, TRUNC_OR_APPEND, delim=','): 
    
    with open(fname, 'w') as ct:
        ct.write('LOAD DATA\n')
        ct.write(TRUNC_OR_APPEND + '\n')
        ct.write('into table ' + tbl_name  + '\n')
        ct.write("fields terminated by '" + delim + "'\n")
        ct.write('optionally Enclosed  by \'"\'\n')
        ct.write('TRAILING NULLCOLS\n')
        ct.write('(\n')
        ct.write(',\n'.join(c for c in col_list ))    
        ct.write(')\n')
435542
def namedb_find_missing_and_extra(cur, record, table_name):
    
    rec_missing = []
    rec_extra = []
    
    # sanity check: all fields must be defined
    name_fields_rows = db_query_execute(cur, 'PRAGMA table_info({})'.format(table_name), ())
    name_fields = []
    for row in name_fields_rows:
        name_fields.append( row['name'] )

    # make sure each column has a record field
    for f in name_fields:
        if f not in record.keys():
            rec_missing.append( f )

    # make sure each record field has a column
    for k in record.keys():
        if k not in name_fields:
            rec_extra.append( k )

    return rec_missing, rec_extra
1139824
def db_create_table(self, table_name, columns):
        
        formatted_columns = ''
        for col in set(columns):
            formatted_columns += '"{}" text, '.format(col.strip('"').strip('\''))
        formatted_columns = formatted_columns.strip(', ')

        create_table_sql = 'CREATE TABLE IF NOT EXISTS {} ({});'.format(
            table_name, formatted_columns
        )
        try:
            cr = self.db_conn.cursor()
            cr.execute(create_table_sql)
        except sqlite3.Error as e:
            self.handle_error(e)
813395
def load_txt_to_sql(tbl_name, src_file_and_path, src_file, op_folder):
    
    if op_folder == '':
        pth = ''
    else:
        pth = op_folder + os.sep
    
    fname_create_script = pth + 'CREATE_' + tbl_name + '.SQL'
    fname_backout_file  = pth + 'BACKOUT_' + tbl_name + '.SQL'
    fname_control_file  = pth + tbl_name + '.CTL'
   
    cols = read_csv_cols_to_table_cols(src_file)
    create_script_staging_table(fname_create_script, tbl_name, cols)    
    create_file(fname_backout_file, 'DROP TABLE ' + tbl_name + ' CASCADE CONSTRAINTS;\n')
    create_CTL(fname_control_file, tbl_name, cols, 'TRUNCATE')
1253081
def get_column_name(self, column_name):
        
        name = pretty_name(column_name)
        if column_name in self._meta.columns:
            column_cls = self._meta.columns[column_name]
            if column_cls.verbose_name:
                name = column_cls.verbose_name
        return name
1167039
def index_name(model, *field_names, **kwargs):
    
    if not len(field_names):
        raise ValueError("At least one field name required")
    using = kwargs.pop('using', DEFAULT_DB_ALIAS)
    if len(kwargs):
        raise ValueError("The only supported keyword argument is 'using'")

    existing_fields = {field.name: field for field in model._meta.fields}
    fields = [existing_fields[name] for name in field_names
              if name in existing_fields]

    if len(fields) != len(field_names):
        unfound_names = set(field_names) - {field.name for field in fields}
        raise ValueError("Fields do not exist: " + ",".join(unfound_names))
    column_names = tuple(field.column for field in fields)
    list_sql = get_list_sql(column_names)

    with connections[using].cursor() as cursor:
        cursor.execute(
            """SELECT `INDEX_NAME`, `SEQ_IN_INDEX`, `COLUMN_NAME`
               FROM INFORMATION_SCHEMA.STATISTICS
               WHERE TABLE_SCHEMA = DATABASE() AND
                     TABLE_NAME = %s AND
                     COLUMN_NAME IN {list_sql}
               ORDER BY `INDEX_NAME`, `SEQ_IN_INDEX` ASC
            """.format(list_sql=list_sql),
            (model._meta.db_table,) + column_names,
        )
        indexes = defaultdict(list)
        for index_name, _, column_name in cursor.fetchall():
            indexes[index_name].append(column_name)

    indexes_by_columns = {tuple(v): k for k, v in indexes.items()}
    try:
        return indexes_by_columns[column_names]
    except KeyError:
        raise KeyError("There is no index on (" + ",".join(field_names) + ")")
1322923
def load(dbname, dbmode='a'):
    
    if dbmode == 'w':
        raise AttributeError("dbmode='w' not allowed for load.")
    db = Database(dbname, dbmode=dbmode)

    return db