def init_db(): dbi.cache_cnf() dbi.use('uwushu_db')
#FindASubstitute #Bianca Pio, Alexandra Bullen-Smith, Margaret Harrigan #CS 304 Final Project #Submitted May 13, 2020 #data.py is the python file containing functions to navigate the database import database import cs304dbi as dbi dsn = dbi.cache_cnf() dbi.use('findasubstitute_db') #sees if an entered username already exists def usernameAvailability(conn, username): curs = dbi.dict_cursor(conn) sql = 'select * from employee1 where username = %s' vals = [username] curs.execute(sql, vals) available = curs.fetchall() if (len(available) == 1): return True #username already exists else: return False #unique username def emailAvailability(conn, email): curs = dbi.dict_cursor(conn) sql = 'select * from employee1 where email = %s' vals = [email] curs.execute(sql, vals)
'''URL for profiles on network, visible to other users.''' @app.route("/profile/<userID>") def alumnusPage(userID): conn = dbi.connect() profileInfo = sqlOperations.profileInfo(conn, userID) return render_template("alumnus.html", result=profileInfo) if __name__ == '__main__': import sys, os if len(sys.argv) > 1: # arg, if any, is the desired port number print(sys.argv[1]) port = int(sys.argv[1]) assert (port > 1024) if not (1943 <= port <= 1950): print('For CAS, choose a port from 1943 to 1950') sys.exit() else: port = os.getuid() cnf = dbi.cache_cnf() # defaults to ~/.my.cnf dbi.use(nameDB) conn = dbi.connect() app.debug = True app.run('0.0.0.0', port)
def init_db(): dbi.cache_cnf() dbi.use('techship_db')
return render_template('form_data.html', method=request.method, form_data={}) @app.route('/testform/') def testform(): return render_template('testform.html') if __name__ == '__main__': import sys, os if len(sys.argv) > 1: # arg, if any, is the desired port number port = int(sys.argv[1]) assert (port > 1024) else: port = os.getuid() # the following database code works for both PyMySQL and SQLite3 dbi.cache_cnf() dbi.use('wmdb') conn = dbi.connect() curs = dbi.dict_cursor(conn) # the following query works for both MySQL and SQLite curs.execute('select current_timestamp as ct') row = curs.fetchone() ct = row['ct'] print('connected to WMDB at {}'.format(ct)) app.debug = True app.run('0.0.0.0', port)
def startup(): dbi.cache_cnf() dbi.use('zipvote_db')
def init_db(): dbi.cache_cnf() dbi.use('foodie_db') # or whatever db
from flask import (Flask, render_template, make_response, url_for, request, redirect, flash, session, send_from_directory, jsonify) from werkzeug.utils import secure_filename import pymysql import cs304dbi as dbi dsn = dbi.cache_cnf() dbi.use('whealth_db') app = Flask(__name__) import random app.secret_key = 'your secret here' # replace that with a random key app.secret_key = ''.join([ random.choice(('ABCDEFGHIJKLMNOPQRSTUVXYZ' + 'abcdefghijklmnopqrstuvxyz' + '0123456789')) for i in range(20) ]) # This gets us better error messages for certain common request errors app.config['TRAP_BAD_REQUEST_ERRORS'] = True staffID = 1409 @app.route('/') def index(): return render_template('main.html') @app.route('/suggest/', methods=["GET", "POST"])
def init_db(): dbi.cache_cnf() dbi.use('coda_db')
def init_db(): dbi.cache_cnf() dbi.use('sclark4_db') # or whatever db
def startup(): dbi.cache_cnf() dbi.use('tbanerji_db')
def init_db(): dbi.cache_cnf() dbi.use('housemate_db')