Q: SQL login verification ALCHEMY Pending

0

I am creating a login to give access to the tool that I am beginning to create, the database is SQL Server

The project structure is this:

├── Project
│   ├── Controllers
│   │   ├── __init__.py
│   │   └── Mapping_Login
│   │       ├── __init__.py
│   │       └── Mapping_login.py
│   ├── __init__.py
│   ├── Models
│   │   ├── Conexao
│   │   │   ├── conexao.py
│   │   │   ├── conexao.pyc
│   │   │   ├── __init__.py
│   │   │   
│   │   ├── __init__.py
│   │   └── sing_in
│   │       ├── __init__.py
│   │       └── register.py
│   └── View
│       ├── __init__.py
│       ├── static_routes.py
│       ├── view_acept_reg.py
│       ├── view_index_page.py
│       └── view_register.py
├── run.py
├── static
│   ├── index.css
│   ├── main.css
│   ├── main.js
│   ├── user_login.png
│   └── util.css
└── templates
    └── printer
       ├── Acept.html
       ├── index.html
       ├── Register.html
       └── TelaInicial.html

I created a database mapping with SQLALCHEMY to do the CRUD

class mapping_log:
    def __init__(self):
        metadata = MetaData()
        self.table = Table('login',metadata,
            Column('id',Integer, primary_key = True),
            Column('usuario',String),
            Column('Senha',String))


    def login(self, Usuario,senha):
         selecionar = self.table.select().where(self.table.c.usuario 
                         == Usuario and self.table.c.Senha == senha)
         conn = __engine__()
         usuarios = conn.execute(selecionar)
         print(usuarios)
         return usuarios
    def insert(self,key_value):
         inserir = self.table.insert()
         conn = __engine__()
         conn.execute(inserir,
              usuario = key_value.get('usuario'),
              Senha = key_value.get('Senha')
          )
    def deletar(self, id ):
        deletar_User =  self.table.delete().where(self.table.c.id == 
        id)        
        conn = __engine__()
        conn.execute(deletar_User)        

I created Routes for the login part I defined def as a test and I'm getting the user login and password from the template, however I'm having a hard time validating it by checking if it exists and allowing access

 # -*- coding utf-8 -*-

 from flask import  render_template, abort, 
      render_template_string,url_for,Blueprint,request
 from Project.Controllers.Mapping_Login.Mapping_login import 
      mapping_log
 from Project import app 


 login_db = mapping_log()

 app_router = Blueprint('app',__name__, url_prefix='/index')
 @app_router.route('/')
      def hellou():
          return render_template('printer/index.html')



 @app_router.route('/initi', methods=['GET', 'POST'])
       def teste():
           usuario = request.form.get('login')
           senha = request.form.get ('password')
           usuarios =  login_db.login(usuario,senha)
           print(usuarios,"pasou aqui ")
           return render_template('printer/TelaInicial.html')



  app.register_blueprint(app_router)    

I do not know where I might be wandering so that this validation does not go right, it goes to "InitialScreen.html" with anything I type in the Login and Password fields!

    
asked by anonymous 30.11.2018 / 10:31

0 answers