from connect import connection, engine, metadata import sqlalchemy as db def add(): return '{"titulo":"Estudiante","accion":"A\u00f1adir","entradas":{"col1":[{"label":"Nombres","type":"text","name":"nombres"},{"label":"Apellidos","type":"text","name":"apellidos"},{"label":"Email","type":"text","name":"email"},{"label":"Grado","type":"text","name":"grado"},{"label":"Fecha de Nacimiento","type":"date","name":"fecha_nac"},{"label":"Genero","type":"select","options":["","Femenino","Masculino","Otro"],"name":"genero"},{"label":"Educaci\u00f3n Especial","type":"checkbox","name":"ed_especial"}],"col2":[{"label":"Direcci\u00f3n 1","name":"direccion1"},{"label":"Direcci\u00f3n 2","type":"text","name":"direccion2"},{"label":"Ciudad","type":"text","name":"ciudad"},{"label":"Zipcode","type":"text","name":"zipcode"},{"label":"Tel\u00e9fono 1","type":"tel","name":"tel1"},{"label":"Tel\u00e9fono 2","type":"tel","name":"tel2"}]}}' def edit(id): return '{"titulo":"Estudiante '+id+'","accion":"Editar","entradas":{"col1":[{"label":"Nombres","type":"text","name":"nombres","value":"Roberta"},{"label":"Apellidos","type":"text","name":"apellidos"},{"label":"Email","type":"text","name":"email"},{"label":"Grado","type":"text","name":"grado"},{"label":"Fecha de Nacimiento","type":"date","name":"fecha_nac"},{"label":"Genero","type":"select","options":["","Femenino","Masculino","Otro"],"name":"genero"},{"label":"Educaci\u00f3n Especial","type":"checkbox","name":"ed_especial"}],"col2":[{"label":"Direcci\u00f3n 1","name":"direccion1"},{"label":"Direcci\u00f3n 2","type":"text","name":"direccion2"},{"label":"Ciudad","type":"text","name":"ciudad"},{"label":"Zipcode","type":"text","name":"zipcode"},{"label":"Tel\u00e9fono 1","type":"tel","name":"tel1"},{"label":"Tel\u00e9fono 2","type":"tel","name":"tel2"}]}}' def get(id): estudiantes = db.Table('estudiantes', metadata, autoload=True, autoload_with=engine)) usuarios = db.Table('usuarios', metadata, autoload=True, autoload_with=engine) query = db.select([estudiantes, usuarios]) query = query.select_from(usuarios.join(role, usuarios.columns.id == estudiantes.columns.user_id)).where(estudiantes.columns.user_id == id) result = connection.execute(query).fetchall() return [{"nombres": "Juana", "apellidos":"Del Barrio", "email": "juana1@gmail.com"},{"nombres": "Juana2", "apellidos":"Del Barrio", "email": "juana2@gmail.com"}] def list(): estudiantes = db.Table('estudiantes', metadata, autoload=True, autoload_with=engine)) usuarios = db.Table('usuarios', metadata, autoload=True, autoload_with=engine) query = db.select([estudiantes, usuarios]) query = query.select_from(usuarios.join(role, usuarios.columns.id == estudiantes.columns.user_id)) # .where(role.columns.user_id == self.id) result = connection.execute(query).fetchall() return [{"nombres": "Juana", "apellidos":"Del Barrio", "email": "juana1@gmail.com"},{"nombres": "Juana2", "apellidos":"Del Barrio", "email": "juana2@gmail.com"}] def main() list() get(1) if __name__ == '__main__': main()