123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
-
- import sqlalchemy as db
-
-
- import cgi
-
-
-
- def escape(htmlstring):
- escapes = {'\"': '"',
- '\'': ''',
- '<': '<',
- '>': '>'}
-
- htmlstring = htmlstring.replace('&', '&')
- for seq, esc in escapes.iteritems():
- htmlstring = htmlstring.replace(seq, esc)
- return htmlstring
-
-
-
- engine = db.create_engine('mysql+pymysql://root:@0.0.0.0/registro_escolar_1')
-
- connection = engine.connect()
-
-
-
- def users():
- query = 'SELECT u.id, u.nombres, u.apellidos, u.email FROM usuarios u'
- result_db = connection.execute(query).fetchall()
-
-
-
- headers = '['
- headers += '{"nombre":"Nombre"}'
- headers += ','
- headers += '{"nombre":"Email"}'
- headers += ','
- headers += '{"nombre":"Informacion"}'
- headers += ','
- headers += '{"nombre":"Editar"}'
- headers += ']'
-
-
-
-
-
-
-
-
-
-
- tabla = '['
- i = 0
- len_result = len(result_db)
- for q in result_db:
- i = i+1
- tabla += '{'
- name = q[1]+' '+q[2]
-
- name = cgi.escape(name)
- tabla += '"Nombre":"'+name+'"'
- tabla += ','
- tabla += '"Email":"'+cgi.escape(q[3])+'"'
- tabla += ','
- tabla += '"user_id":"'+cgi.escape(str(q[0]))+'"'
- tabla += '}'
- if i < len_result:
- tabla += ','
- tabla += ']'
-
-
-
- info = '{'
- info += '"dash_name":"Manejar test"'
- info += ','
- info += '"dash_link":"/admin/ver/"'
- info += ','
- info += '"dash_sub_name":"user Registrados"'
- info += ','
- info += '"add":"Anadir nada"'
- info += ','
- info += '"add_link":"#"'
- info += ','
- info += '"dir1":"#"'
- info += ','
- info += '"dir2":"#"'
- info += '}'
-
-
-
- modal = '{'
- modal += '"infoName":"Ver informacion"'
- modal += ','
- modal += '"editName":"/admin/ver/"'
- modal += '}'
-
-
-
-
-
-
-
-
-
-
-
-
- result = '{"headers":'+headers+',"tabla":'+tabla+',"info":'+info+',"modal":'+modal+'}'
-
-
- return(result)
|