<commit_before>from flask import jsonify, request, g, abort, url_for, current_app, session, flash
from flask.ext.login import LoginManager, current_user
from . import api

from sqlalchemy import create_engine, text
from sqlalchemy.orm import scoped_session, sessionmaker
from app.database import Base
import psycopg2
import psycopg2.extensions
import select



@api.route('/connect/<ip>/<db>')
def connect(ip,db):
    try:
        engine = create_engine('postgresql://gui:AniTa08@' + ip.replace('_','.') +'/' + db, convert_unicode=True)
    
        conn=engine.connect()
        # db_session = scoped_session(sessionmaker(autocommit=False,autoflush=False,bind=engine))
        db_session = scoped_session(sessionmaker(autocommit=False,autoflush=False,bind=conn))
        query_ip_db= 'query_' + ip  + '_' + db
        #  query_ip_db is a string and should be Base's attribute. setattr() is perfect for this job
        setattr(Base,query_ip_db, db_session.query_property())
        flash("Database connect Successful", 'success') # flash message not working, why?
        return 'success'
    except:
        return 'fail'<commit_msg>nothing<commit_after>from flask import jsonify, request, g, abort, url_for, current_app, session, flash
from flask.ext.login import LoginManager, current_user
from . import api

from sqlalchemy import create_engine, text
from sqlalchemy.orm import scoped_session, sessionmaker
from app.database import Base
import psycopg2
import psycopg2.extensions
import select



@api.route('/connect/<ip>/<db>')
def connect(ip,db):
    try:
        engine = create_engine('postgresql://gui:AniTa08@' + ip.replace('_','.') +'/' + db, convert_unicode=True)
    
        conn=engine.connect()
        # db_session = scoped_session(sessionmaker(autocommit=False,autoflush=False,bind=engine))
        db_session = scoped_session(sessionmaker(autocommit=False,autoflush=False,bind=conn))
        query_ip_db= 'query_' + ip  + '_' + db
        #  query_ip_db is a string and should be Base's attribute. setattr() is perfect for this job
        setattr(Base,query_ip_db, db_session.query_property())
        # flash("Database connect Successful", 'success') # flash message not working, why?
        return 'success'
    except:
        return 'fail'
{'fraction_non_alphanumeric': 0.10988526037069726, 'fraction_numerical': 0.00353045013239188, 'mean_word_length': 4.175799086757991, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7346411', 'n_tokens_mistral': 717, 'n_tokens_neox': 691, 'n_words': 175}