本文整理汇总了Python中eulfedora.server.Repository.sparql_query方法的典型用法代码示例。如果您正苦于以下问题:Python Repository.sparql_query方法的具体用法?Python Repository.sparql_query怎么用?Python Repository.sparql_query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eulfedora.server.Repository
的用法示例。
在下文中一共展示了Repository.sparql_query方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from eulfedora.server import Repository [as 别名]
# 或者: from eulfedora.server.Repository import sparql_query [as 别名]
def main(argv):
repo = Repository(root='%s/fedora/' % HOST, username='%s' % fedoraUser, password='%s' % fedoraPass).risearch
s = solr.SolrConnection('%s/solr' % HOST)
query = 'select ?pid where {?pid <fedora-rels-ext:isMemberOfCollection> <info:fedora/dimenovels:40>}'
pids = repo.find_statements(query, language='sparql', type='tuples', flush=None)
csvfile = open ("C:/Users/a1691506/Desktop/bdn.csv", 'wb')
csvwriter = csv.writer(csvfile, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
for dictionary in pids:
for key in dictionary:
p = dictionary[key]
pid = p.replace('info:fedora/', '')
print pid
response = s.query('PID:"%s"' % pid)
results = repo.sparql_query('select ?pid where {?pid <fedora-rels-ext:isMemberOf> <info:fedora/%s> }' % pid)
rows = list(results)
pages = len(rows)
try:
for hit in response.results:
title = hit['mods_title_full_ms'][0]
number = hit['mods_series_number_ms'][0]
date = hit['mods_dateIssued_ms'][0]
csvwriter.writerow([pid, title, number, date, pages])
except:
print "%s failed." % pid
csvfile.close()