title: pymysql 2- applicaions SELECT INSERT Query
body: <p>Application 1 keeps connection open and selects data from database. I need to keep this connection open for my application. Application 2 inserts the data into the database. Application one is only able to see the data that was in the DB at the time of the connection. Even with a new Select Query the data is not up to date. You can see the output below where I started application 2 which started inserting data. When I started application one, up to 5 was already inserted into the DB. Application 2 went on and continued to add new rows up to 9, but Application 1 cannot see the new rows UNLESS I close the connection and re-open it. I am working with very high speeds and the connection time kills my application. I need to be able to leave the connection open the entire time.</p>
  <p>#Applicaion 1</p>
  <pre><code>import pymysql
  import time as t
  
  queryconn = pymysql.connect(host='x, user='x', passwd='x',
                               db='TestDB')
  
  while True:
          queryconncurser = queryconn.cursor()
          # query database
          queryconncurser.execute(f&quot;SELECT * FROM `testQuerys`&quot;)
          items = queryconncurser.fetchall()
          print(items)
  
          t.sleep(4)
  </code></pre>
  <p>output:</p>
  <pre><code>(2,), (3,), (4,), (5,)
  (2,), (3,), (4,), (5,)
  (2,), (3,), (4,), (5,)
  (2,), (3,), (4,), (5,)
  (2,), (3,), (4,), (5,)
  </code></pre>
  <p>#Application 2</p>
  <pre><code>import pymysql
  import time as t
  
  n = 1
  while True:
      queryconn =  pymysql.connect(host='x', user='x', passwd='x', db='TestDB')
      queryconncurser = queryconn.cursor()
      n = n + 1
      # query database
      queryconncurser.execute(f&quot;INSERT INTO testQuerys (testData)  VALUES ({n}) &quot;)
      queryconn.commit()
      print(n)
      t.sleep(4)
      queryconn.close()
  </code></pre>
  <p>Output:</p>
  <pre><code>2
  3
  4
  5
  6
  7
  8
  9
  </code></pre>