本文整理汇总了Python中askomics.libaskomics.rdfdb.QueryLauncher.QueryLauncher.execute_query方法的典型用法代码示例。如果您正苦于以下问题:Python QueryLauncher.execute_query方法的具体用法?Python QueryLauncher.execute_query怎么用?Python QueryLauncher.execute_query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类askomics.libaskomics.rdfdb.QueryLauncher.QueryLauncher
的用法示例。
在下文中一共展示了QueryLauncher.execute_query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete_apikey
# 需要导入模块: from askomics.libaskomics.rdfdb.QueryLauncher import QueryLauncher [as 别名]
# 或者: from askomics.libaskomics.rdfdb.QueryLauncher.QueryLauncher import execute_query [as 别名]
def delete_apikey(self, key):
"""delete an apikey"""
query_laucher = QueryLauncher(self.settings, self.session)
sqa = SparqlQueryAuth(self.settings, self.session)
query_laucher.execute_query(sqa.delete_apikey(key).query)
示例2: empty
# 需要导入模块: from askomics.libaskomics.rdfdb.QueryLauncher import QueryLauncher [as 别名]
# 或者: from askomics.libaskomics.rdfdb.QueryLauncher.QueryLauncher import execute_query [as 别名]
def empty(self):
#empty database
sqb = SparqlQueryBuilder(self.settings, self.request.session)
ql = QueryLauncher(self.settings, self.request.session)
namedGraphs = self.list_named_graphs()
for graph in namedGraphs:
ql.execute_query(sqb.get_delete_query_string(graph).query)
示例3: delete_galaxy
# 需要导入模块: from askomics.libaskomics.rdfdb.QueryLauncher import QueryLauncher [as 别名]
# 或者: from askomics.libaskomics.rdfdb.QueryLauncher.QueryLauncher import execute_query [as 别名]
def delete_galaxy(self):
"""Delete galaxy triple for the user"""
query_laucher = QueryLauncher(self.settings, self.session)
sqa = SparqlQueryAuth(self.settings, self.session)
query_laucher.execute_query(sqa.delete_galaxy(self.username).query)
示例4: deleteMoState
# 需要导入模块: from askomics.libaskomics.rdfdb.QueryLauncher import QueryLauncher [as 别名]
# 或者: from askomics.libaskomics.rdfdb.QueryLauncher.QueryLauncher import execute_query [as 别名]
def deleteMoState(self,urimo):
self.log.debug(' ***** Delete module '+urimo+' on TPS ***** ')
sqb = SparqlQueryBuilder(self.settings, self.session)
ql = QueryLauncher(self.settings, self.session)
ql.execute_query(sqb.prepare_query(
"""
DELETE WHERE { GRAPH <"""+self.graph_modules+"""> { <"""+urimo+"""> ?p ?o } }
"""
).query)
示例5: empty_database
# 需要导入模块: from askomics.libaskomics.rdfdb.QueryLauncher import QueryLauncher [as 别名]
# 或者: from askomics.libaskomics.rdfdb.QueryLauncher.QueryLauncher import execute_query [as 别名]
def empty_database(self):
"""
Delete all triples in the triplestore
"""
self.log.debug("=== DELETE ALL TRIPLES ===")
sqb = SparqlQueryBuilder(self.settings, self.request.session)
ql = QueryLauncher(self.settings, self.request.session)
ql.execute_query(sqb.get_delete_query_string().query)
示例6: add_apikey
# 需要导入模块: from askomics.libaskomics.rdfdb.QueryLauncher import QueryLauncher [as 别名]
# 或者: from askomics.libaskomics.rdfdb.QueryLauncher.QueryLauncher import execute_query [as 别名]
def add_apikey(self, keyname):
"""Add an api key
:param keyname: the keyname
:type keyname: string
"""
query_laucher = QueryLauncher(self.settings, self.session)
sqa = SparqlQueryAuth(self.settings, self.session)
query_laucher.execute_query(sqa.add_apikey(self.username, keyname).query)
示例7: delete_graph
# 需要导入模块: from askomics.libaskomics.rdfdb.QueryLauncher import QueryLauncher [as 别名]
# 或者: from askomics.libaskomics.rdfdb.QueryLauncher.QueryLauncher import execute_query [as 别名]
def delete_graph(self):
"""
Delete triples from a list of graph
"""
self.log.debug("=== DELETE SELECTED GRAPHS ===")
sqb = SparqlQueryBuilder(self.settings, self.request.session)
ql = QueryLauncher(self.settings, self.request.session)
graphs = self.request.json_body['namedGraphs']
for graph in graphs:
self.log.debug("--- DELETE GRAPH : %s", graph)
ql.execute_query(sqb.get_drop_named_graph(graph).query)
#delete metadatas
ql.execute_query(sqb.get_delete_metadatas_of_graph(graph).query)
示例8: list_named_graphs
# 需要导入模块: from askomics.libaskomics.rdfdb.QueryLauncher import QueryLauncher [as 别名]
# 或者: from askomics.libaskomics.rdfdb.QueryLauncher.QueryLauncher import execute_query [as 别名]
def list_named_graphs(self):
sqb = SparqlQueryBuilder(self.settings, self.request.session)
ql = QueryLauncher(self.settings, self.request.session)
res = ql.execute_query(sqb.get_list_named_graphs().query)
namedGraphs = []
for indexResult in range(len(res['results']['bindings'])):
namedGraphs.append(res['results']['bindings'][indexResult]['g']['value'])
return namedGraphs
示例9: empty_database
# 需要导入模块: from askomics.libaskomics.rdfdb.QueryLauncher import QueryLauncher [as 别名]
# 或者: from askomics.libaskomics.rdfdb.QueryLauncher.QueryLauncher import execute_query [as 别名]
def empty_database(self):
"""
Delete all triples in the triplestore
"""
data = {}
self.log.debug("=== DELETE ALL TRIPLES ===")
try:
sqb = SparqlQueryBuilder(self.settings, self.request.session)
ql = QueryLauncher(self.settings, self.request.session)
namedGraphs = self.get_list_named_graphs()
namedGraphs.append(ql.get_param("askomics.graph"))
for graph in namedGraphs:
ql.execute_query(sqb.get_delete_query_string(graph).query)
except Exception as e:
traceback.print_exc(file=sys.stdout)
data['error'] = traceback.format_exc(limit=8)+"\n\n\n"+str(e)
self.log.error(str(e))
return data
示例10: add_galaxy
# 需要导入模块: from askomics.libaskomics.rdfdb.QueryLauncher import QueryLauncher [as 别名]
# 或者: from askomics.libaskomics.rdfdb.QueryLauncher.QueryLauncher import execute_query [as 别名]
def add_galaxy(self, url, key):
"""Connect a galaxy account to Askomics
add triples for the url of galaxy, and the user api key
:param self; url: the galaxy url
:type self; url: string
:param key: the galaxy user api key
:type key: string
"""
# try to connect to the galaxy server
galaxy = GalaxyConnector(self.settings, self.session, url, key)
try:
galaxy.check_galaxy_instance()
except Exception as e:
raise e
query_laucher = QueryLauncher(self.settings, self.session)
sqa = SparqlQueryAuth(self.settings, self.session)
query_laucher.execute_query(sqa.add_galaxy(self.username, url, key).query)
示例11: test_statistics
# 需要导入模块: from askomics.libaskomics.rdfdb.QueryLauncher import QueryLauncher [as 别名]
# 或者: from askomics.libaskomics.rdfdb.QueryLauncher.QueryLauncher import execute_query [as 别名]
def test_statistics(self):
request = testing.DummyRequest()
sqb = SparqlQueryBuilder(self.settings, request.session)
ql = QueryLauncher(self.settings, request.session)
sqb.get_statistics_number_of_triples()
sqb.get_statistics_number_of_entities()
sqb.get_statistics_distinct_classes()
sqb.get_statistics_list_classes()
sqb.get_statistics_nb_instances_by_classe()
sqb.get_statistics_by_startpoint()
sqb.get_list_named_graphs()
res = ql.execute_query(sqb.get_list_named_graphs().query)
for indexResult in range(len(res['results']['bindings'])):
sqb.get_delete_query_string(res['results']['bindings'][indexResult]['g']['value'])
sqb.get_metadatas(res['results']['bindings'][indexResult]['g']['value'])
示例12: get_list_named_graphs
# 需要导入模块: from askomics.libaskomics.rdfdb.QueryLauncher import QueryLauncher [as 别名]
# 或者: from askomics.libaskomics.rdfdb.QueryLauncher.QueryLauncher import execute_query [as 别名]
def get_list_named_graphs(self):
"""
Return a list with all the named graphs.
"""
self.log.debug("=== LIST OF NAMED GRAPHS ===")
sqb = SparqlQueryBuilder(self.settings, self.request.session)
ql = QueryLauncher(self.settings, self.request.session)
res = ql.execute_query(sqb.get_list_named_graphs().query)
namedGraphs = []
for indexResult in range(len(res['results']['bindings'])):
namedGraphs.append(res['results']['bindings'][indexResult]['g']['value'])
return namedGraphs
示例13: build_sparql_query_from_json
# 需要导入模块: from askomics.libaskomics.rdfdb.QueryLauncher import QueryLauncher [as 别名]
# 或者: from askomics.libaskomics.rdfdb.QueryLauncher.QueryLauncher import execute_query [as 别名]
def build_sparql_query_from_json(self,variates,constraintesRelations,limit,sendRequestToTPS):
self.log.debug("variates")
self.log.debug(variates)
self.log.debug("constraintesRelations")
self.log.debug(constraintesRelations)
sqb = SparqlQueryBuilder(self.settings, self.session)
ql = QueryLauncher(self.settings, self.session)
res = ql.execute_query(sqb.get_list_named_graphs().query)
namedGraphs = []
#for indexResult in range(len(res['results']['bindings'])):
# namedGraphs.append(res['results']['bindings'][indexResult]['g']['value'])
req = ""
req += "SELECT DISTINCT "+' '.join(variates)+"\n"
#TODO OFI: External Service do not work and, anyway, graphes have to be selectionned by the user in the UI
#
#for graph in namedGraphs:
# req += "FROM "+ "<"+graph+ ">"+"\n"
req += "WHERE \n"
req += self.buildRecursiveBlock('',constraintesRelations)
if limit != None and limit >0 :
req +=" LIMIT "+str(limit)
sqb = SparqlQueryBuilder(self.settings, self.session)
prefixes = sqb.header_sparql_config(req)
query = prefixes+req
results = {}
if sendRequestToTPS:
ql = QueryLauncher(self.settings, self.session)
results = ql.process_query(query)
else:
# add comment inside query to inform user
query = "# endpoint = "+self.get_param("askomics.endpoint") + "\n" + query
return results,query
示例14: drop_graph
# 需要导入模块: from askomics.libaskomics.rdfdb.QueryLauncher import QueryLauncher [as 别名]
# 或者: from askomics.libaskomics.rdfdb.QueryLauncher.QueryLauncher import execute_query [as 别名]
def drop_graph(self, graph):
sqb = SparqlQueryBuilder(self.settings, self.request.session)
ql = QueryLauncher(self.settings, self.request.session)
ql.execute_query(sqb.get_drop_named_graph(graph).query)
示例15: source_files_overview
# 需要导入模块: from askomics.libaskomics.rdfdb.QueryLauncher import QueryLauncher [as 别名]
# 或者: from askomics.libaskomics.rdfdb.QueryLauncher.QueryLauncher import execute_query [as 别名]
def source_files_overview(self):
"""
Get preview data for all the available files
"""
self.log.debug(" ========= Askview:source_files_overview =============")
sfc = SourceFileConvertor(self.settings, self.request.session)
source_files = sfc.get_source_files()
data = {}
data['files'] = []
# get all taxon in the TS
sqb = SparqlQueryBuilder(self.settings, self.request.session)
ql = QueryLauncher(self.settings, self.request.session)
res = ql.execute_query(sqb.get_all_taxon().query)
taxons_list = []
for elem in res['results']['bindings']:
taxons_list.append(elem['taxon']['value'])
data['taxons'] = taxons_list
for src_file in source_files:
infos = {}
infos['name'] = src_file.name
infos['type'] = src_file.type
if src_file.type == 'tsv':
try:
infos['headers'] = src_file.headers
infos['preview_data'] = src_file.get_preview_data()
infos['column_types'] = []
header_num = 0
for ih in range(0, len(infos['headers'])):
#if infos['headers'][ih].find("@")>0:
# infos['column_types'].append("entity")
#else:
infos['column_types'].append(src_file.guess_values_type(infos['preview_data'][ih], infos['headers'][header_num]))
header_num += 1
except Exception as e:
traceback.print_exc(file=sys.stdout)
infos['error'] = 'Could not read input file, are you sure it is a valid tabular file?'
self.log.error(str(e))
data['files'].append(infos)
elif src_file.type == 'gff':
try:
entities = src_file.get_entities()
infos['entities'] = entities
except Exception as e:
self.log.debug('error !!')
traceback.print_exc(file=sys.stdout)
infos['error'] = 'Could not parse the file, are you sure it is a valid GFF3 file?'
self.log.error('error with gff examiner: ' + str(e))
data['files'].append(infos)
elif src_file.type == 'ttl':
infos['preview'] = src_file.get_preview_ttl()
data['files'].append(infos)
return data