I recently migrated my 2018 CS50 files from c9.io to AWS Cloud9, including my end of course project, which happens to borrow heavily from the CS50 Finance project. I am simply trying to re-run my 2018 files into the new environment. To make the files run in AWS Cloud9, I had to re-install some module in the new environment, but eventually running into the following error when running one of the file, which is meant to upload a bunch of eligible stock tickers from Quandl:
My code:
import quandl, requests from flask import request, current_app from cs50 import SQL db = SQL("sqlite:///formula.db")
db.execute("DELETE FROM coverage") """feedback = requests.get(f"https://www.quandl.com/api/v3/datatables/SHARADAR/SF1.json?ticker={ticker}&qopts.columns=ticker,dimension,datekey,revenue&api_key=rCmomCxddWF7R8bj4xMu")""" """changes to below line from project.new: remove "f" """ feedback = requests.get("https://www.quandl.com/api/v3/datatables/SHARADAR/TICKERS.json?table=SF1&qopts.columns=ticker,name,exchange,isdelisted,category,cusips,siccode,sicsector,sicindustry,famaindustry,sector,industry,scalemarketcap,scalerevenue,currency,location,lastupdated&api_key=rCmomCxddWF7R8bj4xMu") responses = feedback.json() data = responses['datatable']['data'] if not data: db.execute("INSERT INTO test(ticker,calendardate,datekey,reportperiod,lastupdated,cashnequsd,debtusd,ebitusd,fcf,ppnenet,workingcapital,shareswa,de,ebitdausd) VALUES(:ticker,:calendardate,:datekey,:reportperiod,:lastupdated,:cashnequsd,:debtusd,:ebitusd,:fcf,:ppnenet,:workingcapital,:shareswa,:de,:ebitdausd)", ticker='N/A', calendardate='N/A', datekey='N/A', reportperiod='N/A', lastupdated='N/A', cashnequsd='N/A', debtusd='N/A', ebitusd='N/A', fcf='N/A', ppnenet='N/A', workingcapital='N/A', shareswa='N/A', de='N/A', ebitdausd='N/A') elif data == 'NULL': db.execute("INSERT INTO test(ticker,calendardate,datekey,reportperiod,lastupdated,cashnequsd,debtusd,ebitusd,fcf,ppnenet,workingcapital,shareswa,de,ebitdausd) VALUES(:ticker,:calendardate,:datekey,:reportperiod,:lastupdated,:cashnequsd,:debtusd,:ebitusd,:fcf,:ppnenet,:workingcapital,:shareswa,:de,:ebitdausd)", ticker='N/A', calendardate='N/A', datekey='N/A', reportperiod='N/A', lastupdated='N/A', cashnequsd='N/A', debtusd='N/A', ebitusd='N/A', fcf='N/A', ppnenet='N/A', workingcapital='N/A', shareswa='N/A', de='N/A', ebitdausd='N/A') else: for record in data: ticker,name,exchange,isdelisted,category,cusips,siccode,sicsector,sicindustry,famaindustry,sector,industry,scalemarketcap,scalerevenue,currency,location,lastupdated = record db.execute("INSERT INTO coverage(ticker,name,exchange,isdelisted,category,cusips,siccode,sicsector,sicindustry,famaindustry,sector,industry,scalemarketcap,scalerevenue,currency,location,lastupdated) VALUES(:ticker,:name,:exchange,:isdelisted,:category,:cusips,:siccode,:sicsector,:sicindustry,:famaindustry,:sector,:industry,:scalemarketcap,:scalerevenue,:currency,:location,:lastupdated)", ticker=ticker, name=name, exchange=exchange, isdelisted=isdelisted ,category=category, cusips=cusips, siccode=siccode, sicsector=sicsector, sicindustry=sicindustry, famaindustry=famaindustry, sector=sector, industry=industry, scalemarketcap=scalemarketcap, scalerevenue=scalerevenue, currency=currency, location=location, lastupdated=lastupdated)
Error displayed:
Traceback (most recent call last): File "ticker.py", line 6, in db = SQL("sqlite:///formula.db") File "/home/ubuntu/.local/lib/python2.7/site-packages/cs50/sql.py", line 66, in init self.execute("SELECT 1") File "/home/ubuntu/.local/lib/python2.7/site-packages/cs50/flask.py", line 37, in _execute_after if flask.current_app: AttributeError: 'module' object has no attribute 'current_app'
I then opened the last file mentioned ("/home/ubuntu/.local/lib/python2.7/site-packages/cs50/flask.py"), not one i created nor saved on my environment -- guessing it is cs50 library material -- and noticed bunch of lines are flagging modules error, including the current_app one.
Any idea what's going on with the new AWS Cloud9 environment? My sense is there are modules version/out of sync between c9.io and the new IDE. thanks for the help. I'm just trying to re-run files that were fine in c9.io into AWS Cloud9.
thanks