def query(graph, selection, patterns, optionalPatterns=[], initialBindings = {},
          dSCompliance=False, loadContexts=False):
    result = queryObject(graph, patterns, optionalPatterns,
                         initialBindings, dSCompliance, loadContexts)
    if result == None:

        # generate some proper output for the exception :-)
        msg = "Errors in the patterns, no valid query object generated; "
        if isinstance(patterns, GraphPattern):
            msg += ("pattern:\n%s" % patterns)
        else :
            msg += ("pattern:\n%s\netc..." % patterns[0])

        raise SPARQLError(msg)

    return result.select(selection)
Transitory API to preserve backwards-compatibility while refactoring.
dataset/ETHPy150Open RDFLib/rdfextras/rdfextras/sparql/query.py/query--crossover with--dataset/ETHPy150Open cloudera/hue/desktop/core/ext-py/Django-1.6.10/django/db/transaction.py/commit_on_success_unless_managed