title: connect to my sql database via python
body: <p>i'm trying to insert values in mysql database using python on windows 10. I've downloaded mysql-connector-python-2.0.4-py2.7 .</p>
  
  <p>This is my python code : </p>
  
  <pre><code>import MySQLdb
  conn = MySQLdb.connect(host= "localhost",
                    user="root",
                    passwd="1234",
                    db="iot")
  x = conn.cursor()
  
  try:
     x.execute("""INSERT INTO sensors VALUES (%s,%s)""",(25,300))
     conn.commit()
  except:
     conn.rollback()
  
  conn.close()
  </code></pre>
  
  <p>when I run the code I'm getting this error : </p>
  
  <pre><code>IDLE internal error in runcode()
  Traceback (most recent call last):
  
    File "C:\Users\enwan\Anaconda\lib\idlelib\rpc.py", line 235, in asyncqueue
      self.putmessage((seq, request))
    File "C:\Users\enwan\Anaconda\lib\idlelib\rpc.py", line 334, in putmessage
      raise IOError, "socket no longer exists"
  IOError: socket no longer exists
  </code></pre>
  
  <p>Any help ?</p>