Код вызов самой функции
from flask import Flask
from data import db_session
db_session.global_init("C:/Users/Tim/flask-sqlalchemy/db/blogs.sqlite")
app = Flask(__name__)
app.config['SECRET_KEY'] = 'yandexlyceum_secret_key'
def main():
app.run()
if __name__ == '__main__':
main()
вот сама функция которая должна заполнить поля
import datetime
import sqlalchemy
from flask import session
from . import db_session
from .db_session import SqlAlchemyBase
import datetime
import sqlalchemy
from sqlalchemy import orm
from .db_session import SqlAlchemyBase
class User(SqlAlchemyBase):
__tablename__ = 'users'
id = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True, autoincrement=True)
surname = sqlalchemy.Column(sqlalchemy.String, nullable=True)
name = sqlalchemy.Column(sqlalchemy.String, nullable=True)
age = sqlalchemy.Column(sqlalchemy.Integer, nullable=True)
position = sqlalchemy.Column(sqlalchemy.String, nullable=True)
speciality = sqlalchemy.Column(sqlalchemy.String, nullable=True)
address = sqlalchemy.Column(sqlalchemy.String, nullable=True)
email = sqlalchemy.Column(sqlalchemy.String, index=True, unique=True, nullable=True)
hashed_password = sqlalchemy.Column(sqlalchemy.String, nullable=True)
modifed_date = sqlalchemy.Column(sqlalchemy.DateTime, default=datetime.datetime.now)
user = User()
user.surname = "Scott"
user.name = "Ridley"
user.age = 21
user.position = "captain"
user.speciality = "research engineer"
user.address = "module_1"
user.email = "scott_chief@mars.org"
user.hashed_password = "cap"
session.add(user)
а вот ошибка которая выходит RuntimeError: Working outside of request context.
This typically means that you attempted to use functionality that needed
an active HTTP request. Consult the documentation on testing for
information about how to avoid this problem.