Flask import error: No module named app. While creating the database with Sqlite
Question: Hi I am very new to flask and I am trying to set up a database using sqlite
with my app. I have the file structure like this

    
    
    app
    |--Static(folder)
    |--Templates(folder)
    |--__init__.py (empty python file)
    |--models.py(containes table classes)
    |--app.py (application module)
    

inside my app.py file I have the following code

    
    
    import os
    from flask_sqlalchemy import SQLAlchemy
    from flask import Flask, render_template, url_for, request, redirect, flash 
    from datetime import datetime
    from logging import DEBUG
    
    
    basedir = os.path.abspath(os.path.dirname(__file__))
    app = Flask(__name__)
    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(basedir, 'database.db')
    db = SQLAlchemy(app)
    

So when I try to run the command

    
    
    from app.app import db 
    

in the python shell, I get the error saying that "no module named app". Can
anyone tell me what I am doing wrong here?


Answer: You shouldn't need to run

    
    
    from app.app import db
    

This command would import a module from a "app" class called "db" in the file
"app", which you don't have and I don't imagine you're trying to do.

You should just be executing your app from the terminal via

    
    
    python app.py
    

This will just execute the code that is in the app.py file.

You can find more about this by following the flask tutorial
[here](http://flask.pocoo.org/docs/0.10/tutorial/setup/)

