geograpy3: [BUG]OperationalError: no such table: countries
Describe the bug A clear and concise description of what the bug is. [OperationalError: no such table: countries]
`--------------------------------------------------------------------------- OperationalError Traceback (most recent call last) <ipython-input-3-05dee123ffd5> in <module> 1 import geograpy 2 url = ‘https://en.wikipedia.org/wiki/2012_Summer_Olympics’ ----> 3 places = geograpy.get_geoPlace_context(url=url)
~/.conda/envs/WikiCOVID/lib/python3.7/site-packages/geograpy/init.py in get_geoPlace_context(url, text, debug)
22 PlaceContext: the place context
23 ‘’’
—> 24 places=get_place_context(url, text, labels=Labels.geo, debug=debug)
25 return places
26
~/.conda/envs/WikiCOVID/lib/python3.7/site-packages/geograpy/init.py in get_place_context(url, text, labels, debug) 44 e.find_entities(labels=labels) 45 places=e.places —> 46 pc = PlaceContext(places) 47 pc.setAll() 48 return pc
~/.conda/envs/WikiCOVID/lib/python3.7/site-packages/geograpy/places.py in init(self, place_names, setAll, correctMisspelling) 30 self.places = self.normalizePlaces(place_names) 31 if setAll: —> 32 self.setAll() 33 34 def str(self):
~/.conda/envs/WikiCOVID/lib/python3.7/site-packages/geograpy/places.py in setAll(self) 85 Set all context information 86 ‘’’ —> 87 self.set_countries() 88 self.set_regions() 89 self.set_cities()
~/.conda/envs/WikiCOVID/lib/python3.7/site-packages/geograpy/places.py in set_countries(self) 96 countries = [] 97 for place in self.places: —> 98 country=self.getCountry(place) 99 if country is not None: 100 countries.append(country.name)
~/.conda/envs/WikiCOVID/lib/python3.7/site-packages/geograpy/locator.py in getCountry(self, name) 1160 params=(name,name,) 1161 country = None -> 1162 countryRecords=self.sqlDB.query(query,params) 1163 if len(countryRecords)==1: 1164 country=Country.fromRecord(countryRecords[0])
~/.conda/envs/WikiCOVID/lib/python3.7/site-packages/lodstorage/sql.py in query(self, sqlQuery, params) 181 cur=self.c.cursor() 182 if params is not None: –> 183 query = cur.execute(sqlQuery,params) 184 else: 185 query = cur.execute(sqlQuery)
OperationalError: no such table: countries`
To Reproduce Steps to reproduce the behavior:
- Run the example on local, remote, colab, jupyter notebook
Expected behavior A clear and concise description of what you expected to happen. The codes should results list of countries
Screenshots If applicable, add screenshots to help explain your problem.
Environment (please complete the following information):
- OS: MAC / UBUNTU / COLAB
- Python Version 3.9 / 3 / ?
Additional context Add any other context about the problem here.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 28 (5 by maintainers)
Commits related to this issue
- tries fixing #59 — committed to somnathrakshit/geograpy3 by tholzheim 3 years ago
Thanks for pointing it out. There seems to be an issue with some functions in the Locator class not checking if the database is present. I will fix it ASAP.
Working on fixing this issue as shown in this commit https://github.com/somnathrakshit/geograpy3/commit/a7a25148d3252d6caf0cd34f1630fbbbad183b04
@kruttikanadig certainly so
The file was empty so I followed the link @WolfgangFahl mentioned and downloaded it and it works! Thanks!!
You’ll also find the relevant database at https://github.com/somnathrakshit/geograpy3/wiki
Thanks for the information - sorry I’m not a very proficient Python user! I ran the script and found the result was “C:\Users<my account name>”. I moved the directory there and it didn’t initially work but I realised that I needed both the db & db.gz files and then it worked!
Thanks very much for your assistance and @WolfgangFahl.
Now I have a question about usage but I’ll create something in the discussions area…