Без опису

1234567891011121314151617181920212223242526272829303132333435
  1. from connect import connection, engine, metadata
  2. import sqlalchemy as db
  3. def add():
  4. 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"}]}}'
  5. def edit(id):
  6. 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"}]}}'
  7. def get(id):
  8. estudiantes = db.Table('estudiantes', metadata, autoload=True, autoload_with=engine)
  9. usuarios = db.Table('usuarios', metadata, autoload=True, autoload_with=engine)
  10. query = db.select([estudiantes, usuarios])
  11. query = query.select_from(usuarios.join(role, usuarios.columns.id == estudiantes.columns.user_id)).where(estudiantes.columns.user_id == id)
  12. result = connection.execute(query).fetchall()
  13. return result
  14. def list():
  15. estudiantes = db.Table('estudiantes', metadata, autoload=True, autoload_with=engine)
  16. usuarios = db.Table('usuarios', metadata, autoload=True, autoload_with=engine)
  17. query = db.select([estudiantes, usuarios])
  18. query = query.select_from(usuarios.join(role, usuarios.columns.id == estudiantes.columns.user_id)) # .where(role.columns.user_id == self.id)
  19. result = connection.execute(query).fetchall()
  20. return result
  21. def main():
  22. list()
  23. get(1)
  24. if __name__ == '__main__':
  25. main()