# from sqlalchemy import metadata import sqlalchemy as db import cgi ######################### # stack overflow: # Python sanitizing html from a string def escape(htmlstring): escapes = {'\"': '"', '\'': ''', '<': '<', '>': '>'} # This is done first to prevent escaping other escapes. htmlstring = htmlstring.replace('&', '&') for seq, esc in escapes.iteritems(): htmlstring = htmlstring.replace(seq, esc) return htmlstring ######################### # connect to server engine = db.create_engine('mysql+pymysql://root:@0.0.0.0/registro_escolar_1') connection = engine.connect() # estudiantes = db.Table('estudiantes', metadata, autoload=True, autoload_with=engine) # usuarios = db.Table('usuarios', metadata, autoload=True, autoload_with=engine) def users(): query = 'SELECT u.id, u.nombres, u.apellidos, u.email FROM usuarios u' result_db = connection.execute(query).fetchall() ###### headers headers = '[' headers += '{"nombre":"Nombre"}' headers += ',' headers += '{"nombre":"Email"}' headers += ',' headers += '{"nombre":"Informacion"}' headers += ',' headers += '{"nombre":"Editar"}' headers += ']' # headers = '[{"nombre":"Nombre"},{"nombre":"Posicion"},{"nombre":"Informacion"},{"nombre":"Editar"}]' ###### tabla # Visit W3Schools #