def create_database(metadata, DB_NAME): import create_db as cdb cdb.setup_module() cdb.create_tables() '''
def delete_eq(id): if int(request.args['key']) == TOKEN: result = db_controller.delete_eq(int(id)) return jsonify(result) return 'Invalid Token' #Get values by ID @app.route(f"/<id>", methods=["GET"]) def get_eq_by_id(id): if int(request.args['key']) == TOKEN: eq = db_controller.get_by_id(int(id)) return jsonify(eq) return 'Invalid Token' @app.after_request def after_request(response): response.headers[ "Access-Control-Allow-Origin"] = "*" # <- You can change "*" for a domain for example "http://localhost" response.headers["Access-Control-Allow-Credentials"] = "true" response.headers[ "Access-Control-Allow-Methods"] = "POST, GET, OPTIONS, PUT, DELETE" response.headers[ "Access-Control-Allow-Headers"] = "Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization" return response if __name__ == "__main__": create_tables() app.run()
def craft_system(): import create_db as cdb repo.define_meta() cdb.create_tables(metadata)
#! /home/sudeep/anaconda3/bin/python3.6 import sqlite3 import glob import create_db files = glob.glob("*.sqlite") if "schools.sqlite" not in files: create_db.create_tables() def get_stu_id(student_name, school_name): no = create_db.select_school(school_name) student_id = cursor.execute( """SELECT id from """ + create_db.schools[no - 1] + """ WHERE name=?""", (student_name, )).fetchone()[0] return (student_id) def add_marks(student_id, score, school_name): no = create_db.select_school(school_name) cursor.execute( """INSERT INTO """ + create_db.schools[no - 1] + """_marks (stu_id, marks) VALUES (?, ?)""", (student_id, score)) connection.commit() return (None) school = str(input("Please Enter the school name \n"))
def finish_rent(id): end_time = datetime.datetime.now() row_count = query_db("update rents set end_time=? where rent_id=?", (end_time, id), ret_rowcount=True) if row_count == 0: return my_response(error="Rent with id=%s not found" % id, code=404) return my_response() @app.route('/rents/<id>', methods=['GET']) def get_rent(id): res = query_db("""select * from rents where rent_id=?""", (id, )) if len(res) == 0: return my_response(error="Equipment with id=%s not found" % id, code=404) return my_response({"rent": res[0]}) if __name__ == '__main__': if not path.exists(DATABASE): conn = sqlite3.connect(DATABASE) cursor = conn.cursor() create_tables(cursor) cursor.close() conn.close() app.run(debug=True, host='0.0.0.0', port=80)
def main(): create_db.create_tables() view.main_menu()
def craftSystem(): import create_db as cdb cdb.create_tables(metadata)