Prepared query to string

26 views
Skip to first unread message

Laura Morales

unread,
Mar 25, 2018, 3:10:06 PM3/25/18
to rdfli...@googlegroups.com
I can't find any Python library that can help me create parameterized queries. The closest thing I've found is RDFlib's prepared queries. Is there any way that I can use a prepared query object and get a string from it? Something more or less like this

query = prepared_string ('select * where { $sbj a [] }', sbj='<http://example.org/Alice>')

Richard Dijkstra

unread,
Feb 25, 2019, 3:33:35 PM2/25/19
to rdflib-dev
Laura,

I create dynamic queries as follows:

    q = sparql.prepareQuery("""
        SELECT  *
        WHERE {
                ?s local:%s ?o .
                }
                """ % attr,
        initNs = INIT_NS
        )

Richard D
Reply all
Reply to author
Forward
0 new messages