Skip to content

Commit

Permalink
docs(readme): update Python code examples to ConfigDict
Browse files Browse the repository at this point in the history
Also include imports in the example code.
  • Loading branch information
lu-pl authored and b1rger committed Oct 21, 2024
1 parent 1c65983 commit 6cf5403
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,27 @@ retrieves the result set:
The result set can be mapped to a nested Pydantic model like so:

```python
from typing import Annotated

from fastapi import FastAPI
from pydantic import BaseModel, ConfigDict
from rdfproxy import Page, SPARQLBinding, SPARQLModelAdapter


class Work(BaseModel):
class Config:
group_by = "work_name"
model_config = ConfigDict(group_by="work_name")

name: Annotated[str, SPARQLBinding("work_name")]
viafs: Annotated[list[str], SPARQLBinding("viaf")]


class Author(BaseModel):
class Config:
group_by = "nameLabel"
model_config = ConfigDict(group_by="nameLabel")

gnd: str
surname: Annotated[str, SPARQLBinding("nameLabel")]
works: list[Work]
education: Annotated[list[str], SPARQLBinding("educated_atLabel")]


adapter = SPARQLModelAdapter(
target="https://query.wikidata.org/bigdata/namespace/wdq/sparql",
query=query,
Expand Down

0 comments on commit 6cf5403

Please sign in to comment.