title: Nothing is returned when connecting to MySQL database using PyMySQL (using 'self' variable)
body: <p>I am trying test out the db connection to MySQL database using PyMySQL.   I have been trying to put this into a class, but running into problems where the script is now returning nothing.  This is my first time using the 'self' variable.</p>
  
  <ol>
  <li><p>I have a database table called 'items', with the following attributes:</p>
  
  <p><a href="https://i.stack.imgur.com/VeVHr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VeVHr.png" alt="enter image description here"></a></p></li>
  <li><p>My original code is written as follows:</p>
  
  <pre><code>import pymysql.cursors
  
  #Connect to the database
  connection = pymysql.connect(host='localhost',
      user='root',
      password='',
      db='testDB',
      charset='utf8mb4',
      cursorclass=pymysql.cursors.DictCursor)
  
  try:
      with connection.cursor() as cursor:
      #Read a single record
      sql = "SELECT * FROM items"
      cursor.execute(sql)
      result = cursor.fetchone()
      print(result)
  
  finally:
      connection.close()
  </code></pre></li>
  </ol>
  
  <p>This script runs fine and returns the following result: 
  {'id': 2}</p>
  
  <ol start="3">
  <li><p>I have been trying to put this code into a class, where I am now using 'self', but running into problems where the script returns nothing.</p>
  
  <pre><code>import pymysql.cursors
  
  class mySQLTest(object):
  
      def __init__(self):
          self.conn = pymysql.connect(host='localhost',
                               user='root',
                               password='',
                               db='testDB',
                               charset='utf8mb4',
                            cursorclass=pymysql.cursors.DictCursor)
          self.cursor = self.conn.cursor()
  
      def test(self):
          try:
              with self.cursor:
                  sql = "SELECT * FROM items"
                  self.cursor.execute(sql)
                  result = self.cursor.fetchall()
                  print(result)
  
          finally:
              self.conn.close
  </code></pre></li>
  </ol>
  
  <p>When I run this script, nothing is returned (I would expect that values 2,3,4,5 be returned).  It simply states: 'Process finished with exit code 0'.</p>
  
  <p>I think I am doing something wrong when I am defining the function?  Appreciate any help/guidance.</p>