Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Operational error no such table: cu.area #73

Closed
Hamzafarooq01 opened this issue Apr 12, 2023 · 3 comments
Closed

Operational error no such table: cu.area #73

Hamzafarooq01 opened this issue Apr 12, 2023 · 3 comments

Comments

@Hamzafarooq01
Copy link

When I try importing the CPI library after installation it gives me the error:
OperationalError Traceback (most recent call last)
/var/folders/cx/c0rnck312cxbw_4wbq7ylfw80000gn/T/ipykernel_38424/1241436912.py in
----> 1 import cpi

~/opt/anaconda3/lib/python3.9/site-packages/cpi/init.py in
19 # Parse data for use
20 logger.info("Parsing data files from the BLS")
---> 21 areas = parsers.ParseArea().parse()
22 items = parsers.ParseItem().parse()
23 periods = parsers.ParsePeriod().parse()

~/opt/anaconda3/lib/python3.9/site-packages/cpi/parsers.py in parse(self)
58 logger.debug("Parsing area file")
59 object_list = MappingList()
---> 60 for row in self.get_file("cu.area"):
61 obj = Area(row["area_code"], row["area_name"])
62 object_list.append(obj)

~/opt/anaconda3/lib/python3.9/site-packages/cpi/parsers.py in get_file(self, file)
35
36 # Query this file
---> 37 query = cursor.execute(f'SELECT * FROM "{file}"')
38 columns = [d[0] for d in query.description]
39 result_list = [dict(zip(columns, r)) for r in query.fetchall()]

OperationalError: no such table: cu.area

Could someone please help me fix this error

@palewire
Copy link
Owner

How did you install the library? I just installed it from scratch in a fresh pipenv environment and got no errors. See:

U6122976@TR-WT3HM659RF Code % mkdir test-cpi
U6122976@TR-WT3HM659RF Code % cd test-cpi
U6122976@TR-WT3HM659RF test-cpi % pipenv install cpi
Creating a virtualenv for this project...
Pipfile: /Users/U6122976/Code/test-cpi/Pipfile
Using /opt/homebrew/bin/python3 (3.11.2) to create virtualenv...
⠧ Creating virtual environment...created virtual environment CPython3.11.2.final.0-64 in 550ms
  creator CPython3Posix(dest=/Users/U6122976/.local/share/virtualenvs/test-cpi-4DWoFmby, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/Users/U6122976/Library/Application Support/virtualenv)
    added seed packages: pip==23.0, setuptools==67.1.0, wheel==0.38.4
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator

✔ Successfully created virtual environment!
Virtualenv location: /Users/U6122976/.local/share/virtualenvs/test-cpi-4DWoFmby
Creating a Pipfile for this project...
Installing cpi...
Resolving cpi...
Installing...
Adding cpi to Pipfile's [packages] ...
✔ Installation Succeeded
Pipfile.lock not found, creating...
Locking [packages] dependencies...
Building requirements...
Resolving dependencies...
✔ Success!
Locking [dev-packages] dependencies...
Updated Pipfile.lock (6d000f4c1b4a53488f75bfda47703ac17f2636d256e11c5ed4e7a49daf52cbf9)!
Installing dependencies from Pipfile.lock (52cbf9)...
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
U6122976@TR-WT3HM659RF test-cpi % pipenv run python
Python 3.11.2 (main, Feb 16 2023, 02:51:42) [Clang 14.0.0 (clang-1400.0.29.202)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cpi
>>> cpi.inflate(100, 1950)
1214.3360995850621

@palewire
Copy link
Owner

If you ran an update, it looks like we are getting blocked from downloading by bot detection added to the BLS website.

<!DOCTYPE HTML> <html lang="en-us">                      <head>  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Access Denied</title> </head>   <style type="text/css">     .centerDiv     {       width: 60%;       height:200px;       margin: 0 auto;       background-color:#FFFFFF ;     }   </style> <body> <div class="centerDiv">                <h1><a href=https://www.bls.gov><!--img src="/apology_objects/images/01.jpg" border="0"--></a><span style="font-family: Times, serif; color: #990000; font-size: 38px;">Bureau of Labor Statistics</span></h1>     <h2>Access Denied</h2>                               <p>The BLS is committed to providing data promptly and according to established schedules. Automated retrieval programs (commonly called "robots" or "bots") can cause delays and interfere with other customers' timely access to information. Therefore, bot activity that doesn't conform to BLS usage policy is prohibited.</p>                                 <p>We apologize for any inconvenience. If you believe we have made an error, please <a href=https://data.bls.gov/forms/opb.htm?akamai-0.36aa2c17.1681487650.919dabe>contact us</a>.</p>                               <p>Please contact your administrator with the error code: 0.36aa2c17.1681487650.919dabe</p> </div> </body> </html>

@palewire
Copy link
Owner

I've attempted to patch this bug, and better test for its future recurrence. Please upgrade to version 1.0.18 and try again. Assuming it's fixed, I'll close this ticket. If you still have the problem, please speak up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants