(query: str)
| 35 | |
| 36 | |
| 37 | def execute_query(query: str) -> List[str]: |
| 38 | sparql.setQuery(query) |
| 39 | try: |
| 40 | results = sparql.query().convert() |
| 41 | except urllib.error.URLError: |
| 42 | print(query) |
| 43 | # exit(0) |
| 44 | rtn = [] |
| 45 | for result in results['results']['bindings']: |
| 46 | assert len(result) == 1 # only select one variable |
| 47 | for var in result: |
| 48 | rtn.append(result[var]['value'].replace('http://rdf.freebase.com/ns/', '').replace("-08:00", '')) |
| 49 | |
| 50 | return rtn |
| 51 | |
| 52 | def execute_query_with_odbc(query:str) -> List[str]: |
| 53 | global odbc_conn |
no outgoing calls
no test coverage detected