You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Anandh Perumal Konar <an...@ualberta.ca> on 2019/11/01 14:52:56 UTC

connecting to Apache server

Hello Everyone,

I'm new to Apache Jena,
I'm doing some experiments with DBpedia database.
I have uploaded the DBpedia data into the apache Jena Fuseki server.
Now I want to know is there a way to connect to the Apache server from
python.

I found the below code in some forum but I don't understand what is
/path/to/tdbstore and moreover without specifying anything about my apache
server how can it connect to my server.

import jaydebeapi
jclass = "org.apache.jena.jdbc.JenaJDBC"
conn_string = "jdbc:jena:tdb:location=/path/to/tdbstore"
conn = jaydebeapi.connect(jclass, conn_string)
cursor = conn.cursor()
query = """
SELECT DISTINCT ?a
WHERE  {
    ?a ?b ?b .
}
"""
cursor.execute(query)# do something with the results
cursor.close()
conn.close()


I have read about RDFLib for python but that would be very slow when the
data is big.

Any leads will be appreciated.

Thanks,

Re: connecting to Apache server

Posted by Andy Seaborne <an...@apache.org>.

On 05/11/2019 00:12, Anandh Perumal Konar wrote:
> Thanks for the input.
> when tried to query the DB from the local system I get the following error:
> 
> TimeoutError: [WinError 10060] A connection attempt failed because the
> connected party did not properly respond after a period of time, or
> established connection failed because connected host has failed to respond
> 
> any thoughts what could be wrong?

This is a networking error - not related to Jena Fuseki although it may 
not even be running.

Another example, if you have a system web proxy set then this sort of 
thing can also happen.

    Andy


> 
> On Mon, Nov 4, 2019 at 12:00 AM Lorenz Buehmann <
> buehmann@informatik.uni-leipzig.de> wrote:
> 
>>
>> On 03.11.19 02:26, Anandh Perumal Konar wrote:
>>> Thanks for the input.
>>> I was successfully able to implement that.
>>> I have a follow-up question to it, Now that the apache server is running
>> in
>>> my server I wan to query it from my local system.
>> Please call it "Fuseki server" or something, "Apache server" is wha
>> people usually understand as the plain webserver.
>>> I understand I need to change the system name from localhost to my server
>>> name but I'm not sure what file is it. Any suggestions?
>> What do you mean by "file"? Instead of localhost you have to provide the
>> IP address to your server on which Fuseki is running. Clearly, on the
>> server you have to open the port for external access, i.e. your firewall
>> should be configured.
>>>
>>>
>>> Thanks again for your help.
>>>
>>>
>>> On Sat, Nov 2, 2019 at 1:09 AM Lorenz Buehmann <
>>> buehmann@informatik.uni-leipzig.de> wrote:
>>>
>>>> Fuseki provides a standard SPARQL endpoint, i.e. accessible via standard
>>>> HTTP protocol. Just use a Python API like SPARQLWrapper [1] to query the
>>>> data in the Fuseki endpoint and you're done.
>>>>
>>>> By the way, not sure what you mean by "RDFLib slow" - if you mean
>>>> loading the data into the in-memory module, ok. But otherwise,
>>>> SPARQLWrapper provides remote SPARQL endpoint access via HTTP. That's
>>>> the way to go.
>>>>
>>>>
>>>> [1] https://rdflib.github.io/sparqlwrapper/
>>>>
>>>> On 01.11.19 15:52, Anandh Perumal Konar wrote:
>>>>> Hello Everyone,
>>>>>
>>>>> I'm new to Apache Jena,
>>>>> I'm doing some experiments with DBpedia database.
>>>>> I have uploaded the DBpedia data into the apache Jena Fuseki server.
>>>>> Now I want to know is there a way to connect to the Apache server from
>>>>> python.
>>>>>
>>>>> I found the below code in some forum but I don't understand what is
>>>>> /path/to/tdbstore and moreover without specifying anything about my
>>>> apache
>>>>> server how can it connect to my server.
>>>>>
>>>>> import jaydebeapi
>>>>> jclass = "org.apache.jena.jdbc.JenaJDBC"
>>>>> conn_string = "jdbc:jena:tdb:location=/path/to/tdbstore"
>>>>> conn = jaydebeapi.connect(jclass, conn_string)
>>>>> cursor = conn.cursor()
>>>>> query = """
>>>>> SELECT DISTINCT ?a
>>>>> WHERE  {
>>>>>      ?a ?b ?b .
>>>>> }
>>>>> """
>>>>> cursor.execute(query)# do something with the results
>>>>> cursor.close()
>>>>> conn.close()
>>>>>
>>>>>
>>>>> I have read about RDFLib for python but that would be very slow when
>> the
>>>>> data is big.
>>>>>
>>>>> Any leads will be appreciated.
>>>>>
>>>>> Thanks,
>>>>>
>>
> 

Re: connecting to Apache server

Posted by Anandh Perumal Konar <an...@ualberta.ca>.
Thanks for the input.
when tried to query the DB from the local system I get the following error:

TimeoutError: [WinError 10060] A connection attempt failed because the
connected party did not properly respond after a period of time, or
established connection failed because connected host has failed to respond

any thoughts what could be wrong?

On Mon, Nov 4, 2019 at 12:00 AM Lorenz Buehmann <
buehmann@informatik.uni-leipzig.de> wrote:

>
> On 03.11.19 02:26, Anandh Perumal Konar wrote:
> > Thanks for the input.
> > I was successfully able to implement that.
> > I have a follow-up question to it, Now that the apache server is running
> in
> > my server I wan to query it from my local system.
> Please call it "Fuseki server" or something, "Apache server" is wha
> people usually understand as the plain webserver.
> > I understand I need to change the system name from localhost to my server
> > name but I'm not sure what file is it. Any suggestions?
> What do you mean by "file"? Instead of localhost you have to provide the
> IP address to your server on which Fuseki is running. Clearly, on the
> server you have to open the port for external access, i.e. your firewall
> should be configured.
> >
> >
> > Thanks again for your help.
> >
> >
> > On Sat, Nov 2, 2019 at 1:09 AM Lorenz Buehmann <
> > buehmann@informatik.uni-leipzig.de> wrote:
> >
> >> Fuseki provides a standard SPARQL endpoint, i.e. accessible via standard
> >> HTTP protocol. Just use a Python API like SPARQLWrapper [1] to query the
> >> data in the Fuseki endpoint and you're done.
> >>
> >> By the way, not sure what you mean by "RDFLib slow" - if you mean
> >> loading the data into the in-memory module, ok. But otherwise,
> >> SPARQLWrapper provides remote SPARQL endpoint access via HTTP. That's
> >> the way to go.
> >>
> >>
> >> [1] https://rdflib.github.io/sparqlwrapper/
> >>
> >> On 01.11.19 15:52, Anandh Perumal Konar wrote:
> >>> Hello Everyone,
> >>>
> >>> I'm new to Apache Jena,
> >>> I'm doing some experiments with DBpedia database.
> >>> I have uploaded the DBpedia data into the apache Jena Fuseki server.
> >>> Now I want to know is there a way to connect to the Apache server from
> >>> python.
> >>>
> >>> I found the below code in some forum but I don't understand what is
> >>> /path/to/tdbstore and moreover without specifying anything about my
> >> apache
> >>> server how can it connect to my server.
> >>>
> >>> import jaydebeapi
> >>> jclass = "org.apache.jena.jdbc.JenaJDBC"
> >>> conn_string = "jdbc:jena:tdb:location=/path/to/tdbstore"
> >>> conn = jaydebeapi.connect(jclass, conn_string)
> >>> cursor = conn.cursor()
> >>> query = """
> >>> SELECT DISTINCT ?a
> >>> WHERE  {
> >>>     ?a ?b ?b .
> >>> }
> >>> """
> >>> cursor.execute(query)# do something with the results
> >>> cursor.close()
> >>> conn.close()
> >>>
> >>>
> >>> I have read about RDFLib for python but that would be very slow when
> the
> >>> data is big.
> >>>
> >>> Any leads will be appreciated.
> >>>
> >>> Thanks,
> >>>
>

Re: connecting to Apache server

Posted by Lorenz Buehmann <bu...@informatik.uni-leipzig.de>.
On 03.11.19 02:26, Anandh Perumal Konar wrote:
> Thanks for the input.
> I was successfully able to implement that.
> I have a follow-up question to it, Now that the apache server is running in
> my server I wan to query it from my local system.
Please call it "Fuseki server" or something, "Apache server" is wha
people usually understand as the plain webserver.
> I understand I need to change the system name from localhost to my server
> name but I'm not sure what file is it. Any suggestions?
What do you mean by "file"? Instead of localhost you have to provide the
IP address to your server on which Fuseki is running. Clearly, on the
server you have to open the port for external access, i.e. your firewall
should be configured.
>
>
> Thanks again for your help.
>
>
> On Sat, Nov 2, 2019 at 1:09 AM Lorenz Buehmann <
> buehmann@informatik.uni-leipzig.de> wrote:
>
>> Fuseki provides a standard SPARQL endpoint, i.e. accessible via standard
>> HTTP protocol. Just use a Python API like SPARQLWrapper [1] to query the
>> data in the Fuseki endpoint and you're done.
>>
>> By the way, not sure what you mean by "RDFLib slow" - if you mean
>> loading the data into the in-memory module, ok. But otherwise,
>> SPARQLWrapper provides remote SPARQL endpoint access via HTTP. That's
>> the way to go.
>>
>>
>> [1] https://rdflib.github.io/sparqlwrapper/
>>
>> On 01.11.19 15:52, Anandh Perumal Konar wrote:
>>> Hello Everyone,
>>>
>>> I'm new to Apache Jena,
>>> I'm doing some experiments with DBpedia database.
>>> I have uploaded the DBpedia data into the apache Jena Fuseki server.
>>> Now I want to know is there a way to connect to the Apache server from
>>> python.
>>>
>>> I found the below code in some forum but I don't understand what is
>>> /path/to/tdbstore and moreover without specifying anything about my
>> apache
>>> server how can it connect to my server.
>>>
>>> import jaydebeapi
>>> jclass = "org.apache.jena.jdbc.JenaJDBC"
>>> conn_string = "jdbc:jena:tdb:location=/path/to/tdbstore"
>>> conn = jaydebeapi.connect(jclass, conn_string)
>>> cursor = conn.cursor()
>>> query = """
>>> SELECT DISTINCT ?a
>>> WHERE  {
>>>     ?a ?b ?b .
>>> }
>>> """
>>> cursor.execute(query)# do something with the results
>>> cursor.close()
>>> conn.close()
>>>
>>>
>>> I have read about RDFLib for python but that would be very slow when the
>>> data is big.
>>>
>>> Any leads will be appreciated.
>>>
>>> Thanks,
>>>

Re: connecting to Apache server

Posted by Anandh Perumal Konar <an...@ualberta.ca>.
Thanks for the input.
I was successfully able to implement that.
I have a follow-up question to it, Now that the apache server is running in
my server I wan to query it from my local system.
I understand I need to change the system name from localhost to my server
name but I'm not sure what file is it. Any suggestions?


Thanks again for your help.


On Sat, Nov 2, 2019 at 1:09 AM Lorenz Buehmann <
buehmann@informatik.uni-leipzig.de> wrote:

> Fuseki provides a standard SPARQL endpoint, i.e. accessible via standard
> HTTP protocol. Just use a Python API like SPARQLWrapper [1] to query the
> data in the Fuseki endpoint and you're done.
>
> By the way, not sure what you mean by "RDFLib slow" - if you mean
> loading the data into the in-memory module, ok. But otherwise,
> SPARQLWrapper provides remote SPARQL endpoint access via HTTP. That's
> the way to go.
>
>
> [1] https://rdflib.github.io/sparqlwrapper/
>
> On 01.11.19 15:52, Anandh Perumal Konar wrote:
> > Hello Everyone,
> >
> > I'm new to Apache Jena,
> > I'm doing some experiments with DBpedia database.
> > I have uploaded the DBpedia data into the apache Jena Fuseki server.
> > Now I want to know is there a way to connect to the Apache server from
> > python.
> >
> > I found the below code in some forum but I don't understand what is
> > /path/to/tdbstore and moreover without specifying anything about my
> apache
> > server how can it connect to my server.
> >
> > import jaydebeapi
> > jclass = "org.apache.jena.jdbc.JenaJDBC"
> > conn_string = "jdbc:jena:tdb:location=/path/to/tdbstore"
> > conn = jaydebeapi.connect(jclass, conn_string)
> > cursor = conn.cursor()
> > query = """
> > SELECT DISTINCT ?a
> > WHERE  {
> >     ?a ?b ?b .
> > }
> > """
> > cursor.execute(query)# do something with the results
> > cursor.close()
> > conn.close()
> >
> >
> > I have read about RDFLib for python but that would be very slow when the
> > data is big.
> >
> > Any leads will be appreciated.
> >
> > Thanks,
> >
>

Re: connecting to Apache server

Posted by Lorenz Buehmann <bu...@informatik.uni-leipzig.de>.
Fuseki provides a standard SPARQL endpoint, i.e. accessible via standard
HTTP protocol. Just use a Python API like SPARQLWrapper [1] to query the
data in the Fuseki endpoint and you're done.

By the way, not sure what you mean by "RDFLib slow" - if you mean
loading the data into the in-memory module, ok. But otherwise,
SPARQLWrapper provides remote SPARQL endpoint access via HTTP. That's
the way to go.


[1] https://rdflib.github.io/sparqlwrapper/

On 01.11.19 15:52, Anandh Perumal Konar wrote:
> Hello Everyone,
>
> I'm new to Apache Jena,
> I'm doing some experiments with DBpedia database.
> I have uploaded the DBpedia data into the apache Jena Fuseki server.
> Now I want to know is there a way to connect to the Apache server from
> python.
>
> I found the below code in some forum but I don't understand what is
> /path/to/tdbstore and moreover without specifying anything about my apache
> server how can it connect to my server.
>
> import jaydebeapi
> jclass = "org.apache.jena.jdbc.JenaJDBC"
> conn_string = "jdbc:jena:tdb:location=/path/to/tdbstore"
> conn = jaydebeapi.connect(jclass, conn_string)
> cursor = conn.cursor()
> query = """
> SELECT DISTINCT ?a
> WHERE  {
>     ?a ?b ?b .
> }
> """
> cursor.execute(query)# do something with the results
> cursor.close()
> conn.close()
>
>
> I have read about RDFLib for python but that would be very slow when the
> data is big.
>
> Any leads will be appreciated.
>
> Thanks,
>