Exemple #1
0
 def log_request(req: 'flask_request', res: str) -> None:
     """Log details of web requests and results"""
     sleep(9)
     #    raise Exception("Something awfull just happened")
     with UseDataBase(vayuputhraapp.config['dbconfig']) as cursor:
         _SQL = """insert into log(phrase, letters, ip, browser_string, results) values(%s, %s, %s, %s, %s)"""
         cursor.execute(_SQL,
                        (req.form['phrase'], req.form['letters'],
                         req.remote_addr, req.user_agent.browser, res))
def view_the_log() -> 'html':
    with UseDataBase(vayuputhraapp.config['dbconfig']) as cursor:
        _SQL1 = """select phrase, letters, ip, browser_string, results from log"""
        cursor.execute(_SQL1)
        contents = cursor.fetchall()
    titles = ('Phrase', 'Letters', 'Remote_addr', 'User_agent', 'Results')
    return render_template('viewlog.html',
                           the_title='View Log',
                           the_row_titles=titles,
                           the_data=contents)
Exemple #3
0
def log_request(req: 'flask_request', res: str) -> None:
    with UseDataBase(app.config['dbconfig']) as cursor:

        _SQL = """insert into log (phrase,letters,ip,browser_string,results) values (%s,%s,%s,%s,%s)"""
        cursor.execute(_SQL, (
            req.form['phrase'],
            req.form['letters'],
            req.remote_addr,
            req.user_agent.browser,
            res,
        ))
Exemple #4
0
def view_the_log() -> 'html':
    try:
        with UseDataBase(vayuputhraapp.config['dbconfig']) as cursor:
            _SQL1 = """select phrase, letters, ip, browser_string, results from log"""
            cursor.execute(_SQL1)
            contents = cursor.fetchall()
        titles = ('Phrase', 'Letters', 'Remote_addr', 'User_agent', 'Results')
        return render_template('viewlog.html',
                               the_title='View Log',
                               the_row_titles=titles,
                               the_data=contents)
    except ConnectionError as err:
        print("Is you database is switched on? Error:", str(err))
    except CredentialsError as err:
        print("Username/Password issues", str(err))
    except SQLError as err:
        print("Is your Query is correct?", str(err))
    except Exception as err:
        print("Soemthing went wrong", str(err))
    return 'Error'
Exemple #5
0
from dbcm import UseDataBase

dbconfig = {
    'host': '127.0.0.1',
    'user': '******',
    'password': '******',
    'database': 'wordsearchlogDB'
}
print("")
with UseDataBase(dbconfig) as cursor:
    _SQL = """select * from log"""
    cursor.execute(_SQL)
    data = cursor.fetchall()

print(data)