title: How can I display rows using column names without using a loop?
body: <pre><code>import mysql.connector
  
  myDB = pymysql.connect(
    host=&quot;localhost&quot;,
    user=&quot;exampleuser&quot;,
    password=&quot;examplepassword&quot;,
    database=&quot;exampledb&quot;
  )
  
  myCursor = myDB.cursor(dictionary=True)
  msg = &quot;something&quot;
  SQL = &quot;SELECT * FROM `example` WHERE `example`='&quot; + msg + &quot;'&quot;
  myCursor.execute(SQL)
  myResult = myCursor.fetchall()
  
  for row in myResult:
    print(row[&quot;example1&quot;])
  </code></pre>
  <p>How can I do it like this:</p>
  <pre><code>row = someFunctionThatDoesWhatINeed(myResult)
  
  print(row[&quot;example1&quot;])
  </code></pre>
  <p>So, by this, I mean that I do not want to use <code>for</code> loop for the displaying the row's values using the column names.</p>
  <h2>Edit:</h2>
  <p>Like in PHP:</p>
  <pre><code>while ($row = mysqli_fetch_assoc($result)) {
    echo $row[&quot;example1&quot;];
  }
  </code></pre>
  <p>Or:</p>
  <pre><code>$row = mysqli_fetch_assoc($result);
  echo $row[&quot;example1&quot;];
  </code></pre>
  <p>I know that these loops are used for multiple rows. But, it will return only single rows. So, not use for loops, right?</p>
  <p>Also, I will never use <code>fetchone()</code> instead of <code>fetchall()</code>. Don't suggest me examples containing <code>fetchone()</code>!</p>
  <h2>IMPORTANT EDITS:</h2>
  <p>I cannot use any loops unnecessarily when I do not get multiple rows. So, do not suggest loops.</p>
  <p>The List is:</p>
  <pre><code>[{'id': 1, 'name': 'example.tld', 'domainId': '12345678_DOMAIN_tld-example', 'nsgroupId': 1, 'resellerId': 0, 'registrarId': 1, 'ownerHandle': '12242342432ABC', 'techHandle': '12242342432ABC', 'adminHandle': '12242342432ABC', 'billingHandle': '12242342432ABC', 'dnssec': 'unsigned', 'updatedDate': datetime.datetime(2020, 11, 1, 1, 11, 39), 'creationDate': datetime.datetime(2017, 11, 1, 1, 11, 39), 'expirationDate': datetime.datetime(2021, 11, 1, 1, 11, 39)}]
  </code></pre>
  <p>I want to display them like:</p>
  <pre><code>Domain Name: row[name] # Domain Name: example.tld
  </code></pre>