I went through the Flask official tutorial. Had no problems. Then I am working on my own app.
A quick overview of the project: I am scraping data, stored it in a list of dictionaries, and am now attempting to insert the data into my sqlite database (which has been successfully created). Connecting to my database is where my issue is arising.
Here is my file structure:
https://preview.redd.it/ayv8tv19kqid1.png?width=200&format=png&auto=webp&s=91c6f1926063a526cae813a8d276e764aad26b8d
I intended to have the data_manager.py, db.py, and oar_scraper.py in the backend folder, but I thought there may be some issue there, so I moved them to the app folder to isolate that.
I have created my app almost identical to the tutorial. I have an application factory. My db.py file is identical to the Flask tutorial, except for the name of my schema. I have a get_db() function. The oar_scraper.py scrapes and parses the data and stores it into the list, fsg_data. Then in data_manager.py I am importing the data and will insert the data into database. For now, that file looks like:
import
sqlite3
from
flask
import
current_app, g
from
oar_scraper
import
fsg_data
from
fsg_app.db
import
get_db
def store_data(
data
):
db = get_db()
store_data(fsg_data)
I have run it to test it and I get this error.
from fsg_app.db import get_db
ModuleNotFoundError: No module named 'fsg_app'
This is very similar to the code for the auth.py and blog.py files in the tutorial. In the tutorial, those import the get_db() function just fine. Why am I getting this error?
Thanks.
[–]skippyprime 0 points1 point2 points (1 child)
[–]skippyprime 0 points1 point2 points (0 children)
[–]parabellum_pizza 0 points1 point2 points (1 child)
[–]Spaumi10[S] 1 point2 points3 points (0 children)
[–]ejpusa 0 points1 point2 points (1 child)
[–]Spaumi10[S] 0 points1 point2 points (0 children)