Error connecting SQLAlchemy to MYSQL db - Error: While importing 'app', an ImportError was raised

109
January 16, 2022, at 9:00 PM

I'm trying to connect a MySql database to my flask app and I'm getting an import error of app. I have tried various ways and have settled with the create_engine route.

So my code at the moment is

import os
from flask import Flask, jsonify
from flask_jwt_extended import JWTManager
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy import Column, String, Integer, Table, Float, Boolean, create_engine
from auth import auth_routes
app = Flask(__name__)
app.register_blueprint(auth_routes)
db = create_engine(os.environ.get("SQL_DB_URL"))
jwt = JWTManager(app)
user = Table('users', 
            Column('id', Integer, primary_key=True),
            Column('username', String),
            Column('email', String, unique=True),
            Column('password', String))
db.create_all(user)

I have a env file that has the connection string in to my localhost which looks like so:

SQL_DB_URL=mysql+pymysql://graham:password@localhost/DB_DB

I then run into pipshell and run flask run which gives me the following error

* Environment: development
 * Debug mode: on
Usage: flask run [OPTIONS]
Try 'flask run --help' for help.
Error: While importing 'app', an ImportError was raised.
Rent Charter Buses Company
READ ALSO
Android Compose Bottom Navigation

Android Compose Bottom Navigation

I have a problem with compose bottom navigation barWith starting screen to be exact

135
Align the non-paranted objects using js (responsive webite)

Align the non-paranted objects using js (responsive webite)

Here's an example of what I am trying to achieve:

131
How to animate any click event [duplicate]

How to animate any click event [duplicate]

I have written this code to remove an element now I want give any effect to it using jQuery

86
Checking my math for distance between 2 points in miles

Checking my math for distance between 2 points in miles

Hello I am trying to do a calculator of finding the distance between 2 pointsEverything works properly

119