Пример #1
0
def upload():
    if request.method == 'GET':
        return render_template('uploadForm.html')
    elif request.method == 'POST':
        file = request.files['file']
        num = int(request.form['num'])
        print(num)
        # get the filename
        #filename = secure_filename(file.filename)
        # save it to static folder
        file.save("myProject/static/file/client.csv")
        Session = sessionmaker(bind=engine)
        session = Session()
        conn = engine.connect()
        try:
            conn.execute("DROP TABLE inbox_table")
        except sqlalchemy.exc.OperationalError:
            print("The table has been deleted")
        try:
            conn.execute("DROP TABLE dropdown_table_new")
        except sqlalchemy.exc.OperationalError:
            print("The table has been deleted")
        # Commit the changes
        session.commit()
        # Close the session
        session.close()
        # generate new tables
        g = generate("client.csv", "famillesall_04-25-2019.csv", num)
        g.gen()
        return redirect(url_for('index'))
Пример #2
0
def get_data():

    model_id1=request.form['suggestion1']
    model_id2=request.form['suggestion2']
    model_id3=request.form['suggestion3']
    client_id = request.form['client_id']

    df=recommender.update_history2(client_id, model_id1, model_id2, model_id3)
    listToWrite = df.to_dict(orient='records')
    print("***********************************")
    print(listToWrite)
    Session = sessionmaker(bind=engine)
    session = Session()
    metadata = sqlalchemy.schema.MetaData(bind=engine,reflect=True)
    table = sqlalchemy.Table("inbox_table", metadata, autoload=True)

# Inser the dataframe into the database in one bulk
    conn = engine.connect()
    conn.execute(table.insert(), listToWrite)
# Commit the changes
    session.commit()
# Close the session
    session.close()
#get the other stuff to repopulate the page
    return redirect(url_for("index"))
Пример #3
0
def reset():
    # remove the suggestions
    Session = sessionmaker(bind=engine)
    session = Session()
    conn = engine.connect()
    conn.execute("DELETE FROM inbox_table WHERE transaction_id = 'suggestion'")
    # Commit the changes
    session.commit()
    # Close the session
    session.close()
    return redirect(url_for('index'))