Re: [rdflib-dev] SPARQLWrapper: how to interpolate python variables in query

2022-01-08 Thread Robert Alexander
Thank you all so much. I will ponder on all good advice you kindly offered. Will continue on Stackoverflow. I routinely use f strings but was dumbfounded by the concurrent use of the triple quotes :) Being a medical docyor I’m only an amateur 😀. Happy and safe 2022 to you all. Robert Sent from

Re: [rdflib-dev] SPARQLWrapper: how to interpolate python variables in query

2022-01-08 Thread Gunnar Aastrand Grimnes
Using string replace isn't a great idea if you don't trust the input - re: SQL/SPARQL injection and little bobby tables: https://xkcd.com/327/ I don't think it works with SPARQLWrapper - but with the SPARQLStore you can pass your binding as RDFLib terms: dbo = Namespace("http://dbpedia.org/onto

Re: [rdflib-dev] SPARQLWrapper: how to interpolate python variables in query

2022-01-07 Thread Nicholas Car
Hi Robert, Marijane is correct! My favorite way of using variables in RDFlib SPARQL queries is to use string replace() so that I don't have to double-up { and }, so I would do something like... ...I'll put a complete answer in if you re-post this to Stack Overflow please! That's where we like to

Re: [rdflib-dev] SPARQLWrapper: how to interpolate python variables in query

2022-01-07 Thread Marijane White
Hello Robert, You’ll need to use one of Python’s string formatting features, which provide functionality for inserting variables into strings. The current state of the art are f-strings, but note that you will have to double all the curly braces in your query string if you use them because f-st