{"id":19388889,"url":"https://github.com/linkml/linkml-sparql","last_synced_at":"2026-05-18T14:12:31.992Z","repository":{"id":104631119,"uuid":"387649471","full_name":"linkml/linkml-sparql","owner":"linkml","description":"Maps LinkML queries to SPARQL and back (ALPHA)","archived":false,"fork":false,"pushed_at":"2021-07-20T02:31:10.000Z","size":11,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-02-24T20:00:05.082Z","etag":null,"topics":["linked-data","linkml","ontology","orm","queries","rdf","rdflib","semantic-web","sparql"],"latest_commit_sha":null,"homepage":"","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/linkml.png","metadata":{"files":{"readme":"README.md","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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-07-20T02:30:58.000Z","updated_at":"2024-12-17T04:29:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"8623b46a-d5e9-41f8-82d1-ce9f3f0fe584","html_url":"https://github.com/linkml/linkml-sparql","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/linkml/linkml-sparql","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linkml%2Flinkml-sparql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linkml%2Flinkml-sparql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linkml%2Flinkml-sparql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linkml%2Flinkml-sparql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/linkml","download_url":"https://codeload.github.com/linkml/linkml-sparql/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linkml%2Flinkml-sparql/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33180470,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-18T09:27:30.708Z","status":"ssl_error","status_checked_at":"2026-05-18T09:27:28.300Z","response_time":71,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["linked-data","linkml","ontology","orm","queries","rdf","rdflib","semantic-web","sparql"],"created_at":"2024-11-10T10:13:58.410Z","updated_at":"2026-05-18T14:12:31.956Z","avatar_url":"https://github.com/linkml.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# linkml-sparql: ORM for SPARQL endpoints\n\nThis provides a way of querying either in-memory RDF graphs or remote SPARQL endpoints using a LinkML specified datamodel.\n\n## Step 1: Define your datamodel and RDF bindings\n\nAs an example, a small schema for a portion of DBpedia:\n\n```yaml\nid: http://dbpedia.org/ontology/\nimports:\n - linkml:types\nprefixes:\n  dbont: http://dbpedia.org/ontology/\n  dbproperty: http://dbpedia.org/property/\n  dbr: http://dbpedia.org/resource/\n  linkml: https://w3id.org/linkml/\n  geo: http://www.w3.org/2003/01/geo/wgs84_pos#\n  wd: http://www.wikidata.org/entity/\n  rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#\n  rdfs: http://www.w3.org/2000/01/rdf-schema#\n  \ndefault_prefix: dbont\n\nclasses:\n  Thing:\n    slots:\n      - id\n      - label\n      - comment\n      - type\n\n  Food:\n    is_a: Thing\n    exact_mappings:\n      - wd:Q2095\n    slots:\n      - servingTemperature\n      - servingSize\n      - alias\n      - cuisine\n      - ingredientName\n      - origin\n      - region\n      - distributor\n      - approximateCalories\n      - carbohydrate\n      - fat\n      - protein\n```\n\n## Step 2: Create Python dataclasses\n\n```bash\npipenv run gen-python dbont.yaml \u003e dbont.py\n```\n\n## Step 3: Code\n\n```python\n\nfrom dbont import Food\nfrom linkml_sparql import QueryEngine, SparqlEndpoint\n\n\n\n   schema = YAMLGenerator(SCHEMA).schema\n   qe = QueryEngine(schema=schema,\n                         endpoint=SparqlEndpoint(url='http://dbpedia.org/sparql/'),\n                         lang='en')\n   objs = qe.query(type=Food.class_class_curie,\n                        origin='dbr:Scotland',\n                        target_class=Food)\n   for obj in objs:\n       print(f'{obj.id} {obj.label} distributed by {obj.distributor}')\n```\n\n## More documentation\n\nMore documentation coming soon. For now, consult the tests.\n\n## TODOs\n\nFunctionality is very incomplete\n\n - remote querying via DESCRIBE can be inefficient\n - ...lots more\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinkml%2Flinkml-sparql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flinkml%2Flinkml-sparql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinkml%2Flinkml-sparql/lists"}