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

PyCon India 2014 received 143 proposals

Some thoughts on Python 3 adoption

getdefault method for python dictionary