title: Trying to get a error for a function
body: <p>I made a login UI to connect python with sql, using MySQLdb as the module for it.
  The UI work fine it pops up and does it thing the login data are stored in a class for that session.</p>
  
  <p>BUT if you put in wrong login data the program will try to connect but fails which returns an error like this </p>
  
  <pre><code>Error: OperationalError: file C:\Python27\lib\site-packages\MySQLdb\connections.py line 187: 2005 
  </code></pre>
  
  <p>I need an if else command to check if there is a connection to the server. Right now it just trys to connect and goes on to the next function. which work fine when the login data is right. but will be meaningless if the login data is wrong since it will still try to get data from MySQL with the wrong login and will return nothing.</p>