Skip to content

Commit

Permalink
Crear triggers en el main
Browse files Browse the repository at this point in the history
  • Loading branch information
Drago177 committed Nov 21, 2024
1 parent acb77f2 commit f93188e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from flask import Flask
from flask_login import LoginManager
from flask_login import LoginManager
from sqlalchemy import text
from extensiones import db, bcrypt
from routes.asig_operador_vehiculo import asig_operador_vehiculo
from routes.asignaciones_repuestos import asignaciones_repuestos
Expand All @@ -10,6 +11,7 @@
from routes.gastos import gastos
from routes.proveedores_repuesto import proveedores_repuesto
from routes.usuarios import Usuario
from setup import crearTriggers
from validaciones import *
from config import Config
from routes.usuarios import usuarios
Expand Down Expand Up @@ -58,6 +60,13 @@ def load_user(user_id):
app.register_blueprint(modelos_vehiculos)
app.register_blueprint(proveedores_repuesto)

def crear_triggers():
with open('triggers.sql', 'r') as file:
sql = file.read()

with db.engine.connect() as conexion:
conexion.execute(text(sql))

if not os.getenv('ENV'):
os.environ['ENV'] = 'development'
env_file = '.env.development'
Expand All @@ -66,6 +75,7 @@ def load_user(user_id):
if __name__ == '__main__':
with app.app_context():
db.create_all()
crearTriggers()

debuggear = True
if os.getenv('ENV') == 'development':
Expand Down

0 comments on commit f93188e

Please sign in to comment.