def insert_notice(table_name, idx, title, data, link): db_class = dbModule.Database() sql = 'INSERT INTO %s VALUES(%d, "%s", "%s", "%s")' % (table_name, idx, title, data, link) db_class.execute(sql) db_class.commit()
def selectAll(): db_class = dbModule.Database() sql = "SELECT * FROM graduateDB.user" row = db_class.executeAll(sql) return row
def getToken(): if request.method == 'POST': print('start token') token = (request.json)['token'] print(token) print(type(token)) (request.json)['token'] = False data_to_encode = {"some": "payload"} encryption_secret = "016D70400F07E9FC5F9A955B186119ED4F060EE9C9E22237897C6F49179275D1" #비밀키 algorithm = "HS256" # encoded = jwt.encode(data_to_encode, encryption_secre, algorithm=algorithm) payload = jwt.decode(token, encryption_secret, algorithms=[algorithm]) print(payload) db_class = dbModule.Database() sql = "INSERT INTO finderdb_v0.token(userid, createtime) \ VALUES('%s', '%s')" % ( payload['userId'], payload['createTime']) db_class.execute(sql) db_class.commit() return 'success' return 'error'
def sales(): data_db = dbModule.Database() sql = "SELECT * FROM Sales_history" row = data_db.executeAll(sql) for item in row: item['History'] = json.loads(item['History']) return render_template("sales.html", result=row)
def insert(owner, password, front_location, front_after): db_class = dbModule.Database() sql = "INSERT INTO graduateDB.user (owner, password,front_location,front_after) VALUES ('%s','%s','%s','%s')" % ( owner, password, front_location, front_after) print(sql) db_class.execute(sql) db_class.commit()
def error(): data_db = dbModule.Database() sql = "SELECT * FROM Error_detection" row = data_db.executeAll(sql) for item in row: item[ 'Errorimg_id'] = "https://yangjae-team07-bucket.s3.eu-west-2.amazonaws.com/" + item[ 'Errorimg_id'] + ".jpg" return render_template("error.html", result=row)
def password_check(owner, password): db_class = dbModule.Database() sql = "SELECT * FROM graduateDB.user WHERE owner='%s' AND password='******'" % (owner,password) print(sql) row = db_class.executeAll(sql) db_class.commit() print(row[0]) # save session of image_location if row is None: return "no data in DB"
def login(): error = None if request.method == 'GET': return render_template('login.html') else: name = request.form['id'] passw = request.form['pw'] if request.method == 'POST': db_class = dbModule.Database() sql1 = "SELECT user_id,password From user" row1 = db_class.executeAll(sql1) for rows1 in row1: if rows1['user_id'] == name and rows1['password'] == passw: return redirect(url_for('select')) return render_template('login.html')
def auth(self, token): print(token) data_to_encode = {"some": "payload"} encryption_secret = "016D70400F07E9FC5F9A955B186119ED4F060EE9C9E22237897C6F49179275D1" # 비밀키 algorithm = "HS256" payload = jwt.decode(token, encryption_secret, algorithms=[algorithm]) print(payload) db_class = dbModule.Database() sql = "SELECT userid,createtime FROM finderdb_v0.token WHERE userid = '%s'" % ( payload['userId']) row = db_class.executeAll(sql) print(row) #print(payload['createTime']) if row[0]['userid'] == payload['userId']: if row[0]['createtime'].strftime( '%Y-%m-%d %H:%M:%S') == payload['createTime']: return True return False
def deleteToken(): if request.method == 'POST': print('start token') token = (request.json)['token'] (request.json)['token'] = False data_to_encode = {"some": "payload"} encryption_secret = "016D70400F07E9FC5F9A955B186119ED4F060EE9C9E22237897C6F49179275D1" #비밀키 algorithm = "HS256" # encoded = jwt.encode(data_to_encode, encryption_secre, algorithm=algorithm) payload = jwt.decode(token, encryption_secret, algorithms=[algorithm]) print(payload) db_class = dbModule.Database() sql = "DELETE FROM finderdb_v0.token WHERE userid = '%s'" % ( payload['userId']) db_class.execute(sql) db_class.commit() return 'success' return 'error'
def upload(): if request.method == 'POST': #title = request.form['title'] #writer = request.form['writer'] #id = request.form['id'] #content = request.form['content'] #writeDate = request.form['writeDate'] #imgName = request.form['imgName'] auth = True #token = (request.json)['token'] #tokenAuth = tokenModule.TokenAuth() #auth = tokenAuth.auth(token) if auth: file = request.files['uploadedfile'] managerid = request.form['managerid'] category = request.form['category'] uploadFileName = file.filename path = UPLOAD_FOLDER + uploadFileName if file and allowed_file(file.filename): file.save(path) db_class = dbModule.Database() sql = "INSERT INTO finderdb_v0.video(PID, MongoDBID, ManagerID, Category,FilePath, FileName, Extension, Size, RegisterDay) \ VALUES('%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, '%s')" % ( managerid + file.filename, 'testMongoID', managerid, category, UPLOAD_FOLDER, uploadFileName, 'mp4', os.stat(path).st_size, datetime.today()) db_class.execute(sql) db_class.commit() return 'ok' return 'error'
def search(): if request.method == 'POST': db_class = dbModule.Database() name=request.form['nm'] birth = request.form['birth'] print(name) sql = "SELECT * FROM service where 성명 = '"+str(name)+"' and " +str(birth) sql2 = "SELECT * FROM attendance where 성명 = '"+str(name)+"' and " +str(birth) sql3 = "SELECT * FROM award where 성명 = '" + str(name) + "' and " + str(birth) #df=db_class.executePD(sql, [name,birth]) #df2 = db_class.executePD(sql2, [name, birth]) df = db_class.pd(sql) df2 = db_class.pd(sql2) df3 = db_class.pd(sql3) return render_template('simple.html', tables=[df.to_html(classes='data'), df2.to_html(classes='data'), df3.to_html(classes='data')], titles=['A','봉사실적','출석실적','수상'])
import dbModule as db import pandas as pd new_data = pd.read_json('') # 데이터 로드 database = db.Database() qa_sql = "SELECT * FROM leedo.qa_dataset" ig_sql = "SELECT * FROM leedo.imground" dataset_qa = database.execute_all(qa_sql) dataset_ig = database.execute_all(ig_sql) dataset_qa = pd.DataFrame(dataset_qa) dataset_ig = pd.DataFrame(dataset_ig) qa_sql_create = "INSERT INTO `qa_dataset` (`QAID`,`question_ts`,`answer_ts`,`question_message_id`,`answer_message_id`,`questioner_id`,`answerer_id`,`questioner_name`,`answerer_name`,`question_context`,`answer_context`,`channel`) VALUES ();"
def stock(): data_db = dbModule.Database() sql = "SELECT * FROM Item_info" row = data_db.executeAll(sql) return render_template("stock.html", result=row)
columns=["학번", "이름", "총점"]) self.apptreeview.pack() self.apptreeview.column("#0", width=40) self.apptreeview.heading("#0", text="no.") self.apptreeview.column("#1", width=120, anchor="w") self.apptreeview.heading("#1", text="학번", anchor="center") self.apptreeview.column("#2", width=60, anchor="w") self.apptreeview.heading("#2", text="이름", anchor="center") self.apptreeview.column("#3", width=80, anchor="w") self.apptreeview.heading("#3", text="총점", anchor="center") self.apptreeview.bind("<Double-1>", self.OnDoubleClick_2) # Quit button in the lower right corner quit_button = ttk.Button(self.window, text="Quit", command=self.window.destroy) quit_button.grid(row=1, column=3) # Create the entire GUI program db = dbModule.Database() program = Counter_program(db) # Start the GUI event loop program.window.mainloop()
def select(): db_class = dbModule.Database() sql = "SELECT * FROM detection" row = db_class.executeAll(sql) return render_template('showitem.html', items=row)
def insert(owner, password, front_location, align_location, diffuse_location, filename): db_class = dbModule.Database() sql = "INSERT INTO graduateDB.user (owner, password,front_location, align_location, diffuse_location, filename) VALUES ('%s','%s','%s','%s','%s','%s')" % (owner, password,front_location, align_location, diffuse_location, filename) db_class.execute(sql) db_class.commit()
# -- coding: utf-8 -- from flask import Flask, request from flask import render_template import dbModule import requests, json import ast app = Flask(__name__) db_class = dbModule.Database() @app.route('/', methods=['GET']) def index(): #ORDER BY RAND() \ #sql = "select id, title, concat(a.addr1, ' ',a.addr2) addr, (select cat3_nm from TB_TYPE_CODE where cat3 = a.cat3) type, \ sql = "select id, title, SUBSTRING_INDEX(addr1, ' ', 1) addr, firstimage, (select cat3_nm from TB_TYPE_CODE where cat3 = a.cat3) type \ from TB_DESTINATION a \ where firstimage != '' \ limit 0, 32" row = db_class.executeAll(sql) #print(row) return render_template('index.html', result=None, resultData=row, resultUPDATE=None)
def __init__(self): self.db_class = dbModule.Database()