'geograpy3: sqlite3.OperationalError: no such table

I would like to use the geograpy3 package for a city & country mapping of string values, related to locations (like 'Roma, Italy' or just 'Timișoara'). It runs on my venv under OpenSuse 15.3.

Unfortunately, I can't get along with the SQLite DB. My test files always end with errors like:

sqlite3.OperationalError: no such table ...

In detail:

import geograpy
url='https://en.wikipedia.org/wiki/2012_Summer_Olympics_torch_relay'
places = geograpy.get_geoPlace_context(url = url)

print(places)

ends with:

Traceback (most recent call last):
  File "/path/to/geograpy3/examples/example1.py", line 3, in <module>
    places = geograpy.get_geoPlace_context(url = url)
  File "/home/axel/.local/share/virtualenvs/myProject-1oLtBMPc/lib/python3.9/site-packages/geograpy/__init__.py", line 24, in get_geoPlace_context
    places=get_place_context(url, text, labels=Labels.geo, debug=debug)
  File "/home/axel/.local/share/virtualenvs/myProject-1oLtBMPc/lib/python3.9/site-packages/geograpy/__init__.py", line 46, in get_place_context
    pc = PlaceContext(places)
  File "/home/axel/.local/share/virtualenvs/myProject-1oLtBMPc/lib/python3.9/site-packages/geograpy/places.py", line 32, in __init__
    self.setAll()
  File "/home/axel/.local/share/virtualenvs/myProject-1oLtBMPc/lib/python3.9/site-packages/geograpy/places.py", line 87, in setAll
    self.set_countries()
  File "/home/axel/.local/share/virtualenvs/myProject-1oLtBMPc/lib/python3.9/site-packages/geograpy/places.py", line 98, in set_countries
    country=self.getCountry(place)
  File "/home/axel/.local/share/virtualenvs/myProject-1oLtBMPc/lib/python3.9/site-packages/geograpy/locator.py", line 1162, in getCountry
    countryRecords=self.sqlDB.query(query,params)
  File "/home/axel/.local/share/virtualenvs/myProject-1oLtBMPc/lib/python3.9/site-packages/lodstorage/sql.py", line 183, in query
    query = cur.execute(sqlQuery,params)
sqlite3.OperationalError: no such table: countries

What have I missed?



Solution 1:[1]

Look under your $HOME/.geograpy3/locations.db, if the file does not exist or is empty download it from here.

For more information look at this issue: https://github.com/somnathrakshit/geograpy3/issues/59

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Arash Shamaei