a method to retrieve the details for a record in the table 
            
        :param primary_key: string with primary key of record 
        :return: dictionary with record fields
18194
def read(self, primary_key):
    
        ''' 
             
        '''
        
        title = '%s.read' % self.__class__.__name__
        
    # retrieve record object
        # record_object = self.session.query(self.record).filter_by(id=primary_key).first()
        select_statement = self.table.select(self.table.c.id==primary_key)
        record_object = self.session.execute(select_statement).first()
        if not record_object:
            raise ValueError('%s(primary_key=%s) does not exist.' % (title, primary_key))
        
    # reconstruct record details
        record_details = self._reconstruct_record(record_object)
                    
        return record_details
857611
def recordlookup(table, key, dictionary=None):
    

    if dictionary is None:
        dictionary = dict()

    it = iter(table)
    hdr = next(it)
    flds = list(map(text_type, hdr))
    keyindices = asindices(hdr, key)
    assert len(keyindices) > 0, 'no key selected'
    getkey = operator.itemgetter(*keyindices)
    for row in it:
        k = getkey(row)
        rec = Record(row, flds)
        if k in dictionary:
            # work properly with shelve
            l = dictionary[k]
            l.append(rec)
            dictionary[k] = l
        else:
            dictionary[k] = [rec]
    return dictionary
890946
def sql(self):
        
        assert self.in_key and not self.nullable   # primary key attributes are never nullable
        return '`{name}` {type} NOT NULL COMMENT "{comment}"'.format(
            name=self.name, type=self.type, comment=self.comment)
147308
def fact_pk(self):
        
        keys = [c for c in self.fact_table.columns if c.primary_key]
        return keys[0]
1141925
def get_column_info(connection, table_name):
	
	cursor = connection.cursor()
	cursor.execute("SELECT sql FROM sqlite_master WHERE type == 'table' AND name == ?", (table_name,))
	statement, = cursor.fetchone()
	coldefs = re.match(_sql_create_table_pattern, statement).groupdict()["coldefs"]
	return [(coldef.groupdict()["name"], coldef.groupdict()["type"]) for coldef in re.finditer(_sql_coldef_pattern, coldefs) if coldef.groupdict()["name"].upper() not in ("PRIMARY", "UNIQUE", "CHECK")]
1240112
def get_objs_from_record(self, record, key):
        
        uids = self.get_uids_from_record(record, key)
        objs = map(self.get_object_by_uid, uids)
        return dict(zip(uids, objs))
149493
def _convert(cls, record):
        
        if not record:
            return {}

        converted_dict = {}
        for field in cls.conversion:
            key = field[0]
            if len(field) >= 2 and field[1]:
                converted_key = field[1]
            else:
                converted_key = key
            if len(field) >= 3 and field[2]:
                conversion_method = field[2]
            else:
                conversion_method = cls.default_conversion_method
            if len(field) >= 4:
                converter = field[3]
            else:
                converter = None
            try:
                value = conversion_method(record[key])
            except KeyError:
                continue
            if converter:
                value = converter._convert_internal(value)
            if converted_key is APPEND:
                if isinstance(value, list):
                    for v in value:
                        converted_dict.update(v)
                else:
                    converted_dict.update(value)
            else:
                converted_dict[converted_key] = value
        return converted_dict
1228734
def fields_for record_name, record_object = nil, fields_options = {}, &block
      super record_name, record_object, fields_options.merge(builder: self.class), &block
    end
1047972
def get_primary_key(model):
    """"""
    model = get_model(model)
    return (field.name for field in model._meta.fields if field.primary_key).next()
1496
def pks(self):
        """"""
        if self._primary_keys is None:
            self._primary_keys = list(
                self.queryset.values_list('pk', flat=True))
        return self._primary_keys
84517
def info(self):
        
        unique_indexes = set(self._uniqueIndexes)
        return {
            'len': len(self),
            'name': self.table_name,
            'fields': list(_object_attrnames(self[0])) if self else [],
            'indexes': [(iname, self._indexes[iname] in unique_indexes) for iname in self._indexes],
        }
1185200
def get_pk_colnames(table_: Table) -> List[str]:
    
    pk_names = []  # type: List[str]
    for col in table_.columns:
        if col.primary_key:
            pk_names.append(col.name)
    return pk_names
1062029
def primary_keys_for(self, cls: ClassDefinition) -> List[SlotDefinitionName]:
        
        return [slot_name for slot_name in self.all_slots_for(cls)
                if self.schema.slots[slot_name].primary_key or self.schema.slots[slot_name].identifier]
529446
def primary_key(table)
      query = <<-SQL
        SELECT
          pg_attribute.attname,
          format_type(pg_attribute.atttypid, pg_attribute.atttypmod)
        FROM
          pg_index, pg_class, pg_attribute, pg_namespace
        WHERE
          pg_class.oid = $2::regclass AND
          indrelid = pg_class.oid AND
          nspname = $1 AND
          pg_class.relnamespace = pg_namespace.oid AND
          pg_attribute.attrelid = pg_class.oid AND
          pg_attribute.attnum = any(pg_index.indkey) AND
          indisprimary
      SQL
      row = execute(query, [table.split(".", 2)[0], quote_ident_full(table)])[0]
      row && row["attname"]
    end
24505
def get_key_columns(self, cursor, table_name):
        
        source_field_dict = self._name_to_index(cursor, table_name)

        sql = """
select
    COLUMN_NAME = fk_cols.COLUMN_NAME,
    REFERENCED_TABLE_NAME = pk.TABLE_NAME,
    REFERENCED_COLUMN_NAME = pk_cols.COLUMN_NAME
from INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS ref_const
join INFORMATION_SCHEMA.TABLE_CONSTRAINTS fk
    on ref_const.CONSTRAINT_CATALOG = fk.CONSTRAINT_CATALOG
    and ref_const.CONSTRAINT_SCHEMA = fk.CONSTRAINT_SCHEMA
    and ref_const.CONSTRAINT_NAME = fk.CONSTRAINT_NAME
    and fk.CONSTRAINT_TYPE = 'FOREIGN KEY'

join INFORMATION_SCHEMA.TABLE_CONSTRAINTS pk
    on ref_const.UNIQUE_CONSTRAINT_CATALOG = pk.CONSTRAINT_CATALOG
    and ref_const.UNIQUE_CONSTRAINT_SCHEMA = pk.CONSTRAINT_SCHEMA
    and ref_const.UNIQUE_CONSTRAINT_NAME = pk.CONSTRAINT_NAME
    And pk.CONSTRAINT_TYPE = 'PRIMARY KEY'

join INFORMATION_SCHEMA.KEY_COLUMN_USAGE fk_cols
    on ref_const.CONSTRAINT_NAME = fk_cols.CONSTRAINT_NAME

join INFORMATION_SCHEMA.KEY_COLUMN_USAGE pk_cols
    on pk.CONSTRAINT_NAME = pk_cols.CONSTRAINT_NAME
where
    fk.TABLE_NAME = %s"""

        cursor.execute(sql,[table_name])
        relations = cursor.fetchall()

        key_columns = []
        key_columns.extend([(source_column, target_table, target_column) \
            for source_column, target_table, target_column in relations])
        return key_columns
97684
def primary_key(self):
        
        primary_key = self.__current_descriptor.get('primaryKey', [])
        if not isinstance(primary_key, list):
            primary_key = [primary_key]
        return primary_key
999522
def get_recordInfo(self, headers, zoneID, zone, records):
        """"""
        if 'None' in records: #If ['None'] in record argument, query all.
            recordQueryEnpoint = '/' + zoneID + '/dns_records&per_page=100'
            recordUrl = self.BASE_URL + recordQueryEnpoint
            recordRequest = requests.get(recordUrl, headers=headers)
            recordResponse = recordRequest.json()['result']
            dev = []
            num = 0
            for value in recordResponse:
                recordName = recordResponse[num]['name']
                dev.append(recordName)
                num = num + 1
            records = dev
        updateRecords = []
        for record in records:
            if zone in record:
                recordFullname = record
            else:
                recordFullname = record + '.' + zone
            recordQuery = '/' + zoneID + '/dns_records?name=' + recordFullname
            recordUrl = self.BASE_URL + recordQuery
            recordInfoRequest = requests.get(recordUrl, headers=headers)
            recordInfoResponse = recordInfoRequest.json()['result'][0]
            recordID = recordInfoResponse['id']
            recordType = recordInfoResponse['type']
            recordProxy = str(recordInfoResponse['proxied'])
            recordContent = recordInfoResponse['content']
            if recordProxy == 'True':
                recordProxied = True
            else:
                recordProxied = False
            updateRecords.append([recordID, recordFullname, recordType,
                recordContent, recordProxied])
        return updateRecords