Module:MySPARQL: Difference between revisions

From TITAF TANGOWIKI
No edit summary
No edit summary
 
Line 7: Line 7:
     local queryResults = sparql.runQuery(sparqlQuery)
     local queryResults = sparql.runQuery(sparqlQuery)


    -- If queryResults is nil, return an error message
     if not queryResults then
     if not queryResults then
         return "SPARQL query failed! Check endpoint and extension."
         return "SPARQL query failed! Check endpoint and extension."
     end
     end


    -- Return full JSON output to analyze
     return mw.text.jsonEncode(queryResults)
     return mw.text.jsonEncode(queryResults)
end
end


return p
return p

Latest revision as of 20:39, 21 March 2025

Documentation for this module may be created at Module:MySPARQL/doc

local sparql = require('SPARQL') -- Load the SPARQL binding

local p = {}

function p.debugQuery(frame)
    local sparqlQuery = frame.args[1]
    local queryResults = sparql.runQuery(sparqlQuery)

    if not queryResults then
        return "SPARQL query failed! Check endpoint and extension."
    end

    return mw.text.jsonEncode(queryResults)
end

return p