def insert_category(): r = request.form cat_name = "'" + r['cat_name'] + "'" columns = '(name)' data = cat_name query = db.insert(data, 'category', columns) db.run_query(query, default_params) return ''
def insert_note(): r = request.form title = "'" + r['title'] + "'" data = "'" + r['data'] + "'" cat_id = "'" + r['cat_id'] + "'" deleted = "'" + '0' + "'" columns = '(title, data, cat_id, deleted)' data = ','.join([title, data, cat_id, deleted]) query = db.insert(data, 'note', columns) db.run_query(query, default_params) return ''
def foo(): query = ''' SELECT UnitPrice, Quantity FROM invoice_items; ''' results = run_query(query) sum_ = 0 for price, quantity in results: sum_ += price * quantity return str(sum_)
def customers(): query = ''' SELECT * FROM customers ''' country = request.args.get('country') if country: param = f" WHERE Country = '{country}'" query += param order = request.args.get('ordering') if order: param = f" ORDER BY {ordering(order)}" query += param query += ';' return str(run_query(query))
def customers(): query = ''' SELECT * FROM customers ''' country = request.args.get('country') if country: param = f"WHERE Country ='{country}'" query += param filter_args = request.args.get('filter') if filter_args: param = f" AND {filter_and(filter_args)}" query += param order = request.args.get('ordering') if order: param = f" ORDER BY {ordering(order)}" query += param query += ';' print(query) return str(run_query(query))
def delete_note(note_id): query = db.update('note', 'deleted', 1, 'id = ' + note_id) db.run_query(query, default_params) return ''
def get_note(note_id): query = db.select("*", 'note', 'deleted = 0 and id = ' + note_id) result = db.run_query(query, default_params, select=True) return {'data': result}
def get_notes(): query = db.select("*", 'note', 'deleted = 0') result = db.run_query(query, default_params, select=True) return {'data': result}
def get_categories(): query = db.select("*", 'category') result = db.run_query(query, default_params, select=True) return {'data': result}
def foo2(): query = ''' SELECT SUM(UnitPrice * Quantity) FROM invoice_items; ''' return str(run_query(query))
def employees(): query = ''' SELECT * FROM employees; ''' return str(run_query(query))