palewire/cpi

OperationalError: no such table: cu.data.3.AsizeNorthEast

NLATH opened this issue · 3 comments

NLATH commented

I run this in Python

import cpi
cpi.update()

I get this error. It was working till 2 days back.


OperationalError Traceback (most recent call last)
/var/folders/8b/fjq89b5n05ldt2ytmw4pn5j80000gn/T/ipykernel_94105/2037719277.py in
----> 1 from economics import Inflation

~/opt/anaconda3/lib/python3.9/site-packages/economics/init.py in
----> 1 from cpi import CPI
2 from inflation import Inflation

~/opt/anaconda3/lib/python3.9/site-packages/cpi/init.py in
23 periods = parsers.ParsePeriod().parse()
24 periodicities = parsers.ParsePeriodicity().parse()
---> 25 series = parsers.ParseSeries(
26 periods=periods, periodicities=periodicities, areas=areas, items=items
27 ).parse()

~/opt/anaconda3/lib/python3.9/site-packages/cpi/parsers.py in parse(self)
165 def parse(self):
166 self.series_list = self.parse_series()
--> 167 self.parse_indexes()
168 return self.series_list
169

~/opt/anaconda3/lib/python3.9/site-packages/cpi/parsers.py in parse_indexes(self)
195 for file in self.FILE_LIST:
196 # ... and for each file ...
--> 197 for row in self.get_file(file):
198 # Get the series
199 series = self.series_list.get_by_id(row["series_id"])

~/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.data.3.AsizeNorthEast

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>

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.

As a note, I have been getting the same error in August:
Screenshot 2023-08-22 102156