#NEWLINE# def pgconnect( dbname , user = None , host = None , port = None ) : #NEWLINE# #INDENT# 'Connect to a Postgres database using psycopg2' #NEWLINE# user = ( '' if ( user is None ) else ( ' user=%s' % user ) ) #NEWLINE# host = ( '' if ( host is None ) else ( 'host=%s ' % host ) ) #NEWLINE# port = ( '' if ( user is None ) else ( 'port=%d ' % port ) ) #NEWLINE# return connect ( ( '%s%sdbname=%s%s' % ( host , port , dbname , user ) ) , connection_factory = DictConnection )