title: Python MySQLdb - Connection in a class
body: <p>I am making a Python project where I have to seek and retreive data from a database.<br>
  I tried making a class, in which I declare the connection and do my queries, here is moreless what I have so far.  </p>
  
  <pre><code>import MySQLdb
  dbc =("localhost","root","1234","users")
  class sql:
      db = MySQLdb.connect(dbc[0],dbc[1],dbc[2],dbc[3])
      cursor = db.cursor()
  
      def query(self,sql):
          sql.cursor.execute(sql)
          return sql.cursor.fetchone()
  
      def rows(self):
          return sql.cursor.rowcount
  
  sqlI = sql()
  print(sqlI.query("SELECT `current_points` FROM `users` WHERE `nick` = 'username';"))
  </code></pre>
  
  <p>So, the main problem is that the variable <code>db</code> and <code>cursor</code> are not callable from other def's/functions from the same Class. What I'd like to get, is a polished query, where I can make queries and retreive it's content. This would summarize my code, therefore I should do.</p>