def sql_datadelete(): from db.DB import deleteOne, getAll if request.method == 'GET': lname = request.args.get('lname') fname = request.args.get('fname') deleteOne( ''' DELETE FROM data_table where first_name = ? and last_name = ?''', (fname, lname)) results = getAll(''' SELECT * FROM data_table''') msg = 'DELETE FROM data_table WHERE first_name = ' + fname + ' and last_name = ' + lname return render_template('sqldatabase.html', results=results, msg=msg)
def sql_editlink(): from db.DB import getAll, getOne if request.method == 'GET': elname = request.args.get('elname') efname = request.args.get('efname') eresults = getOne( ''' SELECT * FROM data_table where first_name = ? and last_name = ?''', (efname, elname)) results = getAll(''' SELECT * FROM data_table''') return render_template('sqldatabase.html', eresults=eresults, results=results)
def sql_datainsert(): from db.DB import insertOne, getAll if request.method == 'POST': last_name = request.form['last_name'] first_name = request.form['first_name'] address = request.form['address'] city = request.form['city'] state = request.form['state'] zip = request.form['zip'] insertOne( ''' INSERT INTO data_table (first_name,last_name,address,city,state,zip) VALUES (?,?,?,?,?,?) ''', (first_name, last_name, address, city, state, zip)) results = getAll(''' SELECT * FROM data_table''') msg = 'INSERT INTO data_table (first_name,last_name,address,city,state,zip) VALUES (' + first_name + ',' + last_name + ',' + address + ',' + city + ',' + state + ',' + zip + ')' return render_template('sqldatabase.html', results=results, msg=msg)
def sql_dataedit(): from db.DB import insertOne, getAll if request.method == 'POST': old_last_name = request.form['old_last_name'] old_first_name = request.form['old_first_name'] last_name = request.form['last_name'] first_name = request.form['first_name'] address = request.form['address'] city = request.form['city'] state = request.form['state'] zip = request.form['zip'] insertOne( ''' UPDATE data_table set first_name=?,last_name=?,address=?,city=?,state=?,zip=? WHERE first_name=? and last_name=? ''', (first_name, last_name, address, city, state, zip, old_first_name, old_last_name)) results = getAll(''' SELECT * FROM data_table''') msg = 'UPDATE data_table set first_name = ' + first_name + ', last_name = ' + last_name + ', address = ' + address + ', city = ' + city + ', state = ' + state + ', zip = ' + zip + ' WHERE first_name = ' + old_first_name + ' and last_name = ' + old_last_name return render_template('sqldatabase.html', results=results, msg=msg)
def sql_database(): from db.DB import getAll results = getAll(''' SELECT * FROM data_table''') msg = 'SELECT * FROM data_table' return render_template('sqldatabase.html', results=results, msg=msg)