def displayImage(): cursor.execute("""SELECT Cover_Image from ITEM where ISBN = 5533282""") image = cursor.fetchone()[0] #print image print type(image) #image = '/9j/4AAQSkZJRgABAQEALAAsAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCABLADIDASIAAhEBAxEB/8QAGgAAAgMBAQAAAAAAAAAAAAAAAgMABAUBBv/EADQQAAIBAwMCBAMGBgMAAAAAAAECAwQRIQASMQUTBiJBURRhcTKBkdHh8BUjM0JioSSi8f/EABoBAAMBAQEBAAAAAAAAAAAAAAECBAADBQf/xAApEQABAwIEBQQDAAAAAAAAAAABAAIREiEDMUFRYXGRofATgbHhFMHR/9oADAMBAAIRAxEAPwD2lX1bradUZaehMlNFUshXssC8YCC+7i5LOwIxZbHTYetdVPR+n1c3TNtRUzhZIEV2MceTciwsQB62+/jS6yXxS9bWrSQRRUwdRTs+xiQA1zzwTs5yLnUiXxE1HXTSl0qZqmJIo02HswhxvZQTY4Lc5Nh8hr5WWYdDZDNNb+/WTyV8niqMXibrbNUU0fS1lqIIkZgwYlWKlrNtFvQgAZBtfnWn0/qvVa/qpjkoJKWkjkk87xkGRVUADP8Ak2COQuqnTo/FENdTpMIVppah5qiRlVmCkA7MH3LKG58o9NNqZfFXxj9iKHsPULsuqHtxhm5ucggKSeRewHs2KzCJLWBgtnPt98FgTxW6J5SL9k+voddLzCNceZgScce2vNhvFoKRxRxKrPFukkCt2wQzSY3XYA7Re/HAxfXpZDP3H7YAT+0m2osXBGGRBaeR837Ls11WiESz2/og/fqa4XqwTaJCPQ31Nc6Rw6poRNFKZNwa3muM/T9dQRymFV7l2v5mv/rVatqKOlSaeprY4kTMl2+yPpf6aYFilJC1KNgE7WBxzf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j7OpqGoqL4h/EHU0aOHdNSNu6xuoHxT8TU/ArD2nkVYd2z+WoOWN8m4GR/kLcHTOmDxF/FY/jWVaELI8gYIWZi7bUBBuAF2WPrm+eNKeWRZJQHIAOM6GSWRUkIcixHH1P5aoDy5lIY2+sX286rmMI5ysR4fFM8aO21JU3svnVQ1jIVBANrYiFs8nPOnQr4rkrds0kENOe2LoqMQCdzkH3UeTixuDrbqJHWQAMQCnofmNBG7MsrFiSIsG/Gj67nNmhvTJAYNplOk7+5tlrcAYxrjfE522z9Pf8tVpJHRn2uwyPX9+2m1ErrM4DkC3AP01MMM2FvIXUNKuDgXydTVEzSX+0dTSfjndD0yv/9k=' image = base64.encodestring(image) return render_template('image.html',image = image)
def UserLogin(): if request.method == 'POST': if request.form['submitB'] == 'login': userName = request.form['username'] password = request.form['password'] query = """SELECT * FROM CUSTOMER WHERE Customer_ID = %s and Customer_password = %s""" cursor.execute(query,(userName,password)) result = cursor.fetchone() if result is None: return render_template('failure.html') else: session['username'] = request.form['username'] #return render_template('BookSearch.html') return redirect(url_for('Searchbooks')) if request.form['submitB'] == 'register': return redirect(url_for('addCustomer')) return render_template('Userlogin.html')
def user_login(): """This custom module returns user id of the validate user Returns: string: returns the user id of the validated user """ try: user_mail = input('enter user mail : ').strip() password = input('enter password : '******'ascii')) query = "select user_id from user where mail_id =%s and password =%s;" if cursor.execute(query, (user_mail, encoded_pwd)): user_id = cursor.fetchone() print('login') return user_id[0] else: print('Invalid Credentials \n\n--Login Again--\n ') except Exception as exception_e: print("Error", exception_e)
def admin_login(): """This is a function that validates the . Args: admin_mail (string): Admin email address password (string): Admin Password cursor (DB_class): cursor class mydb (DB_class): connection class Returns: string : returns the user id of the validated admin """ try: admin_mail = valid.email_validation(input('enter admin mail ')) password = input("Enter you password") encoded_pwd = base64.b64encode(password.encode('ascii')) query = "select user_id from user \ where mail_id =%s and password =%s and is_admin_flag = %s;" if cursor.execute(query, (admin_mail, encoded_pwd, '1')): print('admin login') admin_uid = cursor.fetchone() return admin_uid[0] print('invalid credentials') except Exception as exception_e: print('Error', exception_e)
def retorna_pessoa(id): cursor.execute("SELECT * FROM pessoa WHERE id = %s", [id]) pessoa = cursor.fetchone() return pessoa
# -*- coding: utf-8 -*- import sys import json with open('env.json', 'r') as env: data=env.read() # parse file env_json = json.loads(data) env_settings = env_json['settings'] from connection import cursor from connection import connection cursor.execute("SELECT * FROM status;") status = cursor.fetchone() try: if sys.argv[1] == "catalog": from catalog import * parser = Catalog() url = env_settings['catalog_url'] last_page = status[0] if status else 9999 elif sys.argv[1] == "one": from item import * parser = Item() url = env_settings['item_url'] last_page = status[1] if status else None if last_page is None: cursor.execute("SELECT max(id) FROM catalog WHERE status = 0;")