{"id":21614764,"url":"https://github.com/eea/sparql-client","last_synced_at":"2026-03-07T22:31:15.141Z","repository":{"id":4708707,"uuid":"5856395","full_name":"eea/sparql-client","owner":"eea","description":"Python API to query a SPARQL endpoint","archived":false,"fork":false,"pushed_at":"2022-02-19T03:34:11.000Z","size":221,"stargazers_count":33,"open_issues_count":10,"forks_count":21,"subscribers_count":47,"default_branch":"master","last_synced_at":"2025-09-29T16:31:08.316Z","etag":null,"topics":["plone","python"],"latest_commit_sha":null,"homepage":"http://pypi.python.org/pypi/sparql-client","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eea.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-09-18T12:58:09.000Z","updated_at":"2025-07-14T09:29:36.000Z","dependencies_parsed_at":"2022-07-14T19:30:42.893Z","dependency_job_id":null,"html_url":"https://github.com/eea/sparql-client","commit_stats":null,"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"purl":"pkg:github/eea/sparql-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eea%2Fsparql-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eea%2Fsparql-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eea%2Fsparql-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eea%2Fsparql-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eea","download_url":"https://codeload.github.com/eea/sparql-client/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eea%2Fsparql-client/sbom","scorecard":{"id":367777,"data":{"date":"2025-08-11","repo":{"name":"github.com/eea/sparql-client","commit":"d7914054ef119541833c616684b1cb42ee02b581"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.5,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":10,"reason":"all changesets reviewed","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-18T12:16:26.641Z","repository_id":4708707,"created_at":"2025-08-18T12:16:26.641Z","updated_at":"2025-08-18T12:16:26.641Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30234482,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-07T19:01:10.287Z","status":"ssl_error","status_checked_at":"2026-03-07T18:59:58.103Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["plone","python"],"created_at":"2024-11-24T22:09:17.085Z","updated_at":"2026-03-07T22:31:15.005Z","avatar_url":"https://github.com/eea.png","language":"Python","funding_links":[],"categories":["Programming"],"sub_categories":["Python"],"readme":"**************************\nSPARQL HTTP client library\n**************************\n.. image:: https://ci.eionet.europa.eu/buildStatus/icon?job=eea/sparql-client/develop\n  :target: https://ci.eionet.europa.eu/job/eea/job/sparql-client/job/develop/display/redirect\n  :alt: develop\n.. image:: https://ci.eionet.europa.eu/buildStatus/icon?job=eea/sparql-client/master\n  :target: https://ci.eionet.europa.eu/job/eea/job/sparql-client/job/master/display/redirect\n  :alt: master\n.. image:: https://img.shields.io/github/v/release/eea/sparql-client\n  :target: https://eggrepo.eea.europa.eu/d/sparql-client/\n  :alt: Release\n  \n`sparql-client` is a SPARQL query library that performs SELECT and ASK queries against a SPARQL endpoint via HTTP.\nIt will automatically convert literals to the coresponding Python types.\n\nAPI based on SPARQL_JavaScript_Library_  by Lee Feigenbaum and Elias Torres. Heavy influence from Juan Manuel Caicedo’s SPARQL library.\n\n.. _SPARQL_JavaScript_Library: https://web.archive.org/web/20120518014957/http://www.thefigtrees.net/lee/sw/sparql.js\n\nAPI\n---\n\nFirst you open a connection to the endpoint::\n\n    s = sparql.Service(endpoint, \"utf-8\", \"GET\")\n\nThen you make the query::\n\n    result = s.query(statement)\n\nIf you have made a SELECT query, then you can read the result with fetchone() or fetchall()::\n\n    for row in result.fetchone():\n\nIf you have made an ASK query, then you can read the result (a boolean value) with hasresult():\n\n    works = result.hasresult()\n\n\nHow it works\n------------\n\n\u003e\u003e\u003e import sparql\n\n\u003e\u003e\u003e q = ('SELECT DISTINCT ?station, ?orbits WHERE { '\n...      '?station a \u003chttp://dbpedia.org/ontology/SpaceStation\u003e . '\n...      '?station \u003chttp://dbpedia.org/property/orbits\u003e ?orbits . '\n...      'FILTER(?orbits \u003e 50000) } ORDER BY DESC(?orbits)')\n\u003e\u003e\u003e result = sparql.query('http://dbpedia.org/sparql', q)\n\n\u003e\u003e\u003e result.variables\n[u'station', u'orbits']\n\n\u003e\u003e\u003e for row in result:\n...     print 'row:', row\n...     values = sparql.unpack_row(row)\n...     print values[0], \"-\", values[1], \"orbits\"\nrow: (\u003cIRI \u003chttp://dbpedia.org/resource/Mir\u003e\u003e, \u003cLiteral \"86331\"^^\u003chttp://www.w3.org/2001/XMLSchema#int\u003e\u003e)\nhttp://dbpedia.org/resource/Mir - 86331 orbits\nrow: (\u003cIRI \u003chttp://dbpedia.org/resource/Salyut_7\u003e\u003e, \u003cLiteral \"51917\"^^\u003chttp://www.w3.org/2001/XMLSchema#int\u003e\u003e)\nhttp://dbpedia.org/resource/Salyut_7 - 51917 orbits\n\nsparql module\n-------------\n\nThe ``sparql`` module can be invoked in several different ways. To quickly run a query use ``query()``. Results are encapsulated in a ``_ResultsParser`` instance:\n\n\u003e\u003e\u003e result = sparql.query(endpoint, query)\n\u003e\u003e\u003e for row in result:\n\u003e\u003e\u003e    print row\n\nCommand-line use\n================\n\n\u003e\u003e\u003e sparql.py [-i] endpoint\n    -i Interactive mode\n\nIf interactive mode is enabled, the program reads queries from the console and then executes them. Use a double line (two ‘enters’) to separate queries.\nOtherwise, the query is read from standard input.\n\nRDF wrapper classes\n===================\n\nclass sparql.RDFTerm\nSuper class containing methods to override. ``sparql.IRI``, ``sparql.Literal`` and ``sparql.BlankNode`` all inherit from ``sparql.RDFTerm``.\n\n``n3()``\n\nReturn a Notation3 representation of this term.\n\n``class sparql.IRI(value)``\n\nAn RDF resource.\n\n``class sparql.Literal(value, datatype=None, lang=None)``\n\nLiterals. These can take a data type or a language code.\n\n``class sparql.BlankNode(value)``\n\nBlank node. Similar to IRI but lacks a stable identifier.\n\nQuery utilities\n===============\n\n``class sparql.Service(endpoint, qs_encoding='utf-8')``\n\nThis is the main entry to the library. The user creates a Service, then sends a query to it. If we want to have persistent connections, then open them here.\n\n``class sparql._ResultsParser(fp)``\n\nParse the XML result.\n\n``__iter__()``\n\nSynonim for fetchone().\n\n``fetchall()``\n\nLoop through the result to build up a list of all rows. Patterned after DB-API 2.0.\n\n``fetchone()``\n\nFetches the next set of rows of a query result, returning a list. An empty list is returned when no more rows are available. If the query was an ASK request, then an empty list is returned as there are no rows available.\n\n``hasresult()``\n\nASK queries are used to test if a query would have a result. If the query is an ASK query there won’t be an actual result, and fetchone() will return nothing. Instead, this method can be called to check the result from the ASK query.\n\nIf the query is a SELECT statement, then the return value of hasresult() is None, as the XML result format doesn’t tell you if there are any rows in the result until you have read the first one.\n\n``sparql.parse_n3_term(src)``\n\nParse a Notation3 value into a RDFTerm object (IRI or Literal).\n\nThis parser understands IRIs and quoted strings; basic non-string types (integers, decimals, booleans, etc) are not supported yet.\n\n``sparql.unpack_row(row, convert=None, convert_type={})``\n\nConvert values in the given row from RDFTerm objects to plain Python values: IRI is converted to a unicode string containing the IRI value; BlankNode is converted to a unicode string with the BNode’s identifier, and Literal is converted based on its XSD datatype.\n\nThe library knows about common XSD types (STRING becomes unicode, INTEGER and LONG become int, DOUBLE and FLOAT become float, DECIMAL becomes Decimal, BOOLEAN becomes bool). If the python-dateutil library is found, then DATE, TIME and DATETIME are converted to date, time and datetime respectively. For other conversions, an extra argument convert may be passed. It should be a callable accepting two arguments: the serialized value as a unicode object, and the XSD datatype.\n\n``sparql.query(endpoint, query)``\n\nConvenient method to execute a query. Exactly equivalent to:\n\n``sparql.Service(endpoint).query(query)``\n\nConversion of data types\n------------------------\n\nThe library will automatically convert typed literals to a coresponding\nsimple type in Python. Dates are also converted if the dateutil_ library is\navailable.\n\n.. _dateutil: http://labix.org/python-dateutil\n\n\nRunning the unit tests\n----------------------\n\nIf you have nose_ installed, just run ``nosetests`` in the top-level directory.\nSome tests require the python-dateutil_ (version 1.5) or mock_ libraries.\nTested under Python 2.4 through 2.7.\n\n.. _nose: http://somethingaboutorange.com/mrl/projects/nose/\n.. _python-dateutil: http://niemeyer.net/python-dateutil\n.. _mock: http://www.voidspace.org.uk/python/mock/\n\nInstalling sparql-client\n------------------------\n\nThe ``sparql-client`` library is available from PyPI and has no dependencies. Installation is as simple as:\n\n    pip install sparql-client\n\nWe recommend also instlaling ``python-dateutil``, to enable parsing of dates and times from query results\n\nLicense\n-------\nThe contents of this package are subject to the Mozilla Public\nLicense Version 1.1 (the \"License\"); you may not use this package\nexcept in compliance with the License. You may obtain a copy of\nthe License at http://www.mozilla.org/MPL/\n\nSoftware distributed under the License is distributed on an \"AS\nIS\" basis, WITHOUT WARRANTY OF ANY KIND, either express or\nimplied. See the License for the specific language governing\nrights and limitations under the License.\n\nThe Original Code is SPARQL client version 1.0.\n\nThe Initial Owner of the Original Code is European Environment\nAgency (EEA). Portions created by Eau de Web for EEA are\nCopyright (C) European Environment Agency. All Rights Reserved.\n\n\nAuthors\n-------\n* Søren Roug, EEA\n* Alex Morega, Eau de Web\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feea%2Fsparql-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feea%2Fsparql-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feea%2Fsparql-client/lists"}