Issue
I created an SQLite3 database, called page.db.
I am trying to use it in python.
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
import sqlite3
app=Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI']="sqlite:////mnt/home/cc/page.db'
db=SQLAlchemy(app)
class tabb(db.Model):
name=db.Column(db.Username,primary_key=True)
After writing this code, I enter python shell and run the command from main import db
. It shows an error saying:
ModuleNotFoundError: No module named 'main'
How can I fix this?
Solution
Are you sure the filname is main and that you are in the same directory as main.py when opening the python interpreter?
Answered By – Arjun
This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0