Singleton pattern for a database connection

I think I understood Singleton pattern, any suggestion?

from pyPgSQL import PgSQL

class Database(object):
_sigletons = {}
def __new__(cls):
if cls not in cls._sigletons:
cls._connection = PgSQL.connect(database='dbname',
user='username',
password='passwd',
host='hostname')
cls._sigletons[cls] = object.__new__(cls)
pass
return cls._sigletons[cls]

def __init__(self):
self.connection = Database._connection
pass

def cursor(self):
return self.connection.cursor()

#other methods follows here

#just to test logjam

Popular posts from this blog

New location for Python Testing Tools Taxonomy

PyCon India 2014 received 143 proposals

To the Indian Python Programming Community, Thank you for the award