I am trying to build a class using Python in order to handle all interactions with MySQL databases. 
I have installed the MySQLdb module and tested the connection to the databases using a simple code.
When I run the following code:

```
import MySQLdb

db = MySQLdb.connect ( host="localhost", user="root" , passwd="xxxxxxx" , db= "some_db")
cursor = db.cursor()
s = cursor.execute ("SELECT * FROM some_table")
#Retrive a record to test it all went well...
t = cursor.fetchall()
for x in t:
print x
db.commit()
db.close()

```

The above code worked fine , it connected to the "some\_db" database retrieved the one record from the "some\_table" table.

However, When I run the code listed below , which consists of a section of a class using the same logic , I get an error thrown . The idea behind the class is to open any database and as many connections as one might wish to open, perform queries etc . Please bear in mind that the following is just a section of class, more functions and what-have- you will be added. 

The code is as follows:

```
import MySQLdb

class d_con (object):
    def __init__ (self, host, user , passwd , db ):
        self.host = host
        self.user = user
        self.passwd = passwd
        self.db = db
        self.d_b = MySQLdb.connect( host = self.host , user = self.user ,  passwd = self.passwd , db = self.db )
        #Test the connection...
        self.cur = self.d_b.cursor()
        self.disp = self.cur.execute ("SELECT VERSION()")
        print self.disp

    def close_connection(self):
        print "...Initializing connection closure..."
        self.d_b.close()

    #More function will be added , I am just testing the constructor.

if __name__ == "__main__ " :
    a = d_con()

else: 
    print ( " d_con class is imported , please instantiate an object in the fashion a = datacon.d_con() . ")

```

When I import the file containing the above code, it executes and prints the statement asking to instantiate the class. After I instantiate the class

```
a=datacon.d_con("localhost" , "root" , "xxxxxxx" , "some_db" ) 

```

this error get thrown:

```
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "datacon.py", line 8, in __init__
    self.d_b = MySQLdb.connect( self.host , self.user ,  self.passwd ,  self.db )
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/MySQLdb/__init__.py", line 81, in Connect
    return Connection(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-   packages/MySQLdb/connections.py", line 193, in __init__
    super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (1049, "Unknown database 'some_table'")

```

Rest assured that I have, repeatedly, checked that the parameters of the MySQLdb.connect () are correct. Besides, I, even, have hardwired the parameters in the constructor to make sure that there are no typos when instantiating the class. Every time, I have the same error.

Since I am new to Python , I am not sure whether the class file has trouble importing the MySQLdb module or if there is a problem of variable scope . The MySQLdb module did import successfully when I executed the code at the top of this conversation using the same database and the same MySQL credentials!
Could you guys help with this?
Thanks in advance. 

Ps: I am running all this on Mac Os 10.12