title: AttributeError: type object 'Database' has no attribute 'scoreDB'
body: <p>I'm trying to connect to Python using AWS RDS during the process of making games using pygame and open source. When I run it, it says &quot;AttributeError: type object 'Database' has no attribute 'scoreDB' &quot;</p>
  <p><strong>shooting_game.py</strong></p>
  <pre class="lang-py prettyprint-override"><code>import pygame
  from database import Database
  
  def main():
      hiScores=Database().getScores()
  
  if __name__ == '__main__':
      while(main()):
          pass
  </code></pre>
  <p><strong>database.py</strong></p>
  <pre class="lang-py prettyprint-override"><code>
  import pymysql
  
  class Database(object):
      numScores = 15
      def __init__(self,host='database-1.c79ahye2go7m.ap-northeast-2.rds.amazonaws.com',user='admin',password='letskirin',db='hiScores',charset='utf8'):
          self.scoreDB=pymysql.connect(host=host,user=user,password=password,db=db,charset=charset)
          self.cursor=self.scoreDB.cursor(pymysql.cursors.DictCursor)
      @staticmethod
      def getSound(self,music=False):
          curs = self.scoreDB.cursor(pymysql.cursors.DictCursor)
          if music:
              curs.execute(&quot;CREATE TABLE if not exists music (setting integer)&quot;)
              curs.execute(&quot;SELECT * FROM music&quot;)
          else:
              curs.execute(&quot;CREATE TABLE if not exists sound (setting integer)&quot;)
              curs.execute(&quot;SELECT * FROM sound&quot;)
          self.scoreDB.commit()
          setting = curs.fetchall()
          curs.close()
          return bool(setting[0][0]) if len(setting) &gt; 0 else False
  
      @staticmethod
      def setSound(self,setting, music=False):
          curs = self.scoreDB.cursor()
          if music:
              curs.execute(&quot;DELETE FROM music&quot;)
              curs.execute(&quot;INSERT INTO music VALUES (?)&quot;, (setting,))
          else:
              curs.execute(&quot;DELETE FROM sound&quot;)
              curs.execute(&quot;INSERT INTO sound VALUES (?)&quot;, (setting,))
          self.scoreDB.commit()
          curs.close()
  
      @classmethod
      def getScores(self):
          curs = self.scoreDB.cursor()
  
          curs.execute('''CREATE TABLE if not exists scores
                       (name text, score integer, accuracy real)''')
          curs.execute(&quot;SELECT * FROM scores ORDER BY score DESC&quot;)
          self.scoreDB.commit()
          hiScores = curs.fetchall()
          curs.close()
          return hiScores
  
      @staticmethod
      def setScore(self,hiScores,entry):
          curs = self.scoreDB.cursor()
  
          if len(hiScores) == Database.numScores:
              lowScoreName = hiScores[-1][0]
              lowScore = hiScores[-1][1]
              curs.execute(&quot;DELETE FROM scores WHERE (name = ? AND score = ?)&quot;,
                        (lowScoreName, lowScore))
          curs.execute(&quot;INSERT INTO scores VALUES (?,?,?)&quot;, entry)
          self.scoreDB.commit()
          curs.close()
  
  
  </code></pre>
  <p><strong>ERROR message</strong></p>
  <pre><code>Traceback (most recent call last):
    File &quot;c:\Users\giuni27\ossp\Base_shooting-game\shooting_game.py&quot;, line 683, in &lt;module&gt;
      while(main()):
    File &quot;c:\Users\giuni27\ossp\Base_shooting-game\shooting_game.py&quot;, line 127, in main
      hiScores=Database.getScores()
    File &quot;c:\Users\giuni27\ossp\Base_shooting-game\database.py&quot;, line 43, in getScores
      curs = self.scoreDB.cursor()
  AttributeError: type object 'Database' has no attribute 'scoreDB
  </code></pre>
  <p>I tried to find the reason and implement it as it is, but I couldn't fix the error. I would appreciate it if you could help me with a beginner developer.</p>