See this code within an API of mine that generated RDF from content in a 
Postgres DB:

https://github.com/CSIRO-enviro-informatics/gnaf-dataset/blob/master/model/address.py#L716

You can see an rdflib in-memory graph is created (‘g’) and then Namespaces for 
it are declared and bound to it. Triples are then added to that graph using 
g.add(()).

To get and RDF file from the in-memory graph, just do 
g.serialize(format=‘turtle’) or whatever format you like.

Nick

— 
Dr Nicholas Car
Data Systems Architect
SURROUND Australia
0477 560 177
[email protected]

> On 11 Feb 2020, at 6:54 am, [email protected] wrote:
> 
> 
> I want to create below tripples using RDFLIB in python and add it to apache 
> jena database. I am not exactly getting how can I create classes and 
> peoperties using RDFLIB. Please let me know regarding this.
> 
> ```
> State a rdfs:Class .
> :City a rdfs:Class .
> :locatedIn a rdf:Property .
> :capitalOf rdfs:subPropertyOf :locatedIn . 
> :capitalOf rdfs:domain :City .
> :capitalOf rdfs:range :State .
> ```
> 
> and also for this
> 
> 
> ```
> Example:UsedCarForSale    RDF:type    RDF:Class
> Example:Price RDF:type RDFS:Property
> Example:PastOwners RDF:Type RDFS:Property
> ```
> -- 
> http://github.com/RDFLib
> --- 
> You received this message because you are subscribed to the Google Groups 
> "rdflib-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rdflib-dev/9d57e692-4fe9-4225-b6f0-94b81b18bb32%40googlegroups.com.

-- 
http://github.com/RDFLib
--- 
You received this message because you are subscribed to the Google Groups 
"rdflib-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rdflib-dev/6CB61BCF-A2BA-45D0-83AD-02F89390814E%40surroundaustralia.com.

Reply via email to