oшибка:
….site-packages/flask_sqlalchemy/__init__.py:851: UserWarning: Neither SQLALCHEMY_DATABASE_URI nor SQLALCHEMY_BINDS is set. Defaulting SQLALCHEMY_DATABASE_URI to “sqlite : ///:memory:”.
Версия python 3.8
app.py
from flask import Flask,session from flask_sqlalchemy import SQLAlchemy from flask_migrate import Migrate import os from sqlalchemy.ext.declarative import declarative_base from sqlalchemy import create_engine from config import Configuration project_root = os.path.dirname(__file__) template_path = os.path.join(project_root, './templates') app = Flask(__name__,template_folder=template_path) app.config.from_object(Configuration) db = SQLAlchemy(app) migrate = Migrate(app,db) Base = declarative_base() engine = create_engine(Configuration.SQLALCHEMY_DATABASE_URL, convert_unicode=True, echo=False) Base.metadata.reflect(engine)
config.py
import os class Configuration(): APPLICATION_DIR=os.path.dirname(os.path.realpath(__file__)) TEMPLATES_AUTO_RELOADED=True SECRET_KEY='' DEBUG=True SQLALCHEMY_DATABASE_URL="mysql+pymysql://root:gothic1321@localhost/site" SQLALCHEMY_TRACK_MODIFICATIONS = False SQLALCHEMY_POOL_SIZE = 200 SQLALCHEMY_MAX_OVERFLOW = 5 SQLALCHEMY_POOL_RECYCLE = 5
models.py
import re,datetime from app import db, Base class tUsers(db.Model): id=db.Column(db.Integer, primary_key=True) login=db.Column(db.String(120), nullable=False) password=db.Column(db.String(12), nullable=False)