code: def to_record(cls, attr_names, values):
          
  
          try:
              # from a namedtuple to a dict
              values = values._asdict()
          except AttributeError:
              pass
  
          try:
              # from a dictionary to a list
              return [cls.__to_sqlite_element(values.get(attr_name)) for attr_name in attr_names]
          except AttributeError:
              pass
  
          if isinstance(values, (tuple, list)):
              return [cls.__to_sqlite_element(value) for value in values]
  
          raise ValueError("cannot convert from {} to list".format(type(values)))
docs: Convert values to a record to be inserted into a database.
  
          :param list attr_names:
              List of attributes for the converting record.
          :param values: Values to be converted.
          :type values: |dict|/|namedtuple|/|list|/|tuple|
          :raises ValueError: If the ``values`` is invalid.