code: def get_DID_subdomain(self, did, cur=None):
          
          did = str(did)
  
          try:
              did_info = parse_DID(did)
              assert did_info['name_type'] == 'subdomain', 'Not a subdomain DID'
          except:
              raise ValueError("Invalid DID: {}".format(did))
          
          original_address = did_info['address']
          name_index = did_info['index']
  
          # find the initial subdomain (the nth subdomain created by this address)
          cmd = 'SELECT fully_qualified_subdomain FROM {} WHERE owner = ? AND sequence = ? ORDER BY parent_zonefile_index, zonefile_offset LIMIT 1 OFFSET ?;'.format(self.subdomain_table)
          args = (original_address, 0, name_index)
  
          cursor = None
          if cur is None:
              cursor = self.conn.cursor()
          else:
              cursor = cur
  
          subdomain_name = None
  
          rows = db_query_execute(cursor, cmd, args)
          for r in rows:
              subdomain_name = r['fully_qualified_subdomain']
              break
  
          if not subdomain_name:
              raise SubdomainNotFound('Does not correspond to a subdomain: {}'.format(did))
  
          # get the current form
          subrec = self.get_subdomain_entry(subdomain_name, cur=cur)
          subrec.did_info = did_info
          return subrec
docs: Get a subdomain, given its DID
          Raise ValueError if the DID is invalid
          Raise SubdomainNotFound if the DID does not correspond to a subdomain