Actually it's not that complicated.
import maya as cmds
connectionList = cmds.listConnections('QUERYNODE' , source = True , destination = True , Plugs = True )
or if you want to query an attribute directly :
import maya as cmds
connectionList = cmds.listConnections('QUERYNODE.ATTR' , source = True , destination = True , Plugs = True )
legend :
if source = True :
Give the attributes/objects that are on the "source" side of connection to the given object
if destination = True :
Give the attributes/objects that are on the "destination" side of connection to the given object
if plugs = True :
If true, return the connected attribute names; if false, return the connected object names only