Example #1
0
def initCandidateVsPost(candidate):
    pprint(candidate)
    # mycursor = mydb.cursor()
    conn = mysql.connect()
    mycursor = conn.cursor()
    mycursor.execute(
        "SELECT title, idcareer, salary, sex, category, position, diploma, experience, address, idpost FROM post"
    )
    posts = mycursor.fetchall()
    for job in posts:
        title = compare_title(candidate[0], job[0])
        career = compare_career(candidate[1], job[1])
        salary = compare_salary(candidate[2], job[2])
        sex = compare_sex(candidate[3], job[3])
        category = compare_category(candidate[4], job[4])
        position = compare_position(candidate[5], job[5])
        diploma = compare_diploma(candidate[6], job[6])
        experience = compare_experience(candidate[7], job[7])
        address = compare_address(candidate[8], job[8])
        score_val = score(title, career, salary, sex, category, position,
                          diploma, experience, address)
        if score_val > 0.75:
            try:
                sql = "INSERT INTO job_candidate (idjob, idcandidate, score) VALUES (%s, %s,%s) ON DUPLICATE KEY UPDATE score = VALUES(score);"
                mycursor.execute(sql, (job[9], candidate[9], score_val))
                # mydb.commit()
                conn.commit()
            except:
                print("Fail Insert!")
Example #2
0
def select_users():
	cursor = mysql.connect().cursor()
	cursor.execute("SELECT id, username, first_name, last_name FROM users")
	users = cursor.fetchall()
	s = ""
	for u in users:
		s += str(u) + "<br \\>"
	return s
Example #3
0
    def __init__(self, limit, config_path):

        self.conn = db.connect(config_path)
        self.cursor = self.conn.cursor()
        self.url = "https://data.cityofchicago.org/resource/ijzp-q8t2.json"
        self.limit = limit
        config = parse(config_path)
        self.socrata_key = config["socrata.key"]
Example #4
0
 def __init__(self, limit, config_path):
     
     self.conn = db.connect(config_path)
     self.cursor = self.conn.cursor()
     self.url = "https://data.cityofchicago.org/resource/ijzp-q8t2.json"
     self.limit = limit
     config = parse(config_path)
     self.socrata_key = config["socrata.key"]
def sql():
    cursor = mysql.connect().cursor()
    cmd = request.args.get("command")
    if cmd != None:
        cursor.execute(cmd)
        return str(
            cursor.fetchall()
        ) + '<br><br><form action="sql"><input type="text" name="command" placeholder="SQL command"></input></form>'
    else:
        return '<form action="sql"><input type="text" name="command" placeholder="SQL command"></input></form>'
Example #6
0
def initValueByCandidate():
    # mycursor = mydb.cursor()
    conn = mysql.connect()
    mycursor = conn.cursor()
    mycursor.execute(
        "SELECT title, career, salary, sex, category, position, diploma, experience, address, idstudent FROM student"
    )
    candidates = mycursor.fetchall()
    for candidate in candidates:
        initCandidateVsPost(candidate)
Example #7
0
 def __init__(self, log = 1):
     json_data=open('config/config.json').read()
     data = loads(json_data)
     self.token = str(data['github_access_token'])
     self.params = {'access_token':self.token, 'per_page':100}
     self.root_url = "https://api.github.com"
     self.options = {}
     self.options['log'] = log 
     self.conn = db.connect()
     self.cursor = self.conn.cursor()
Example #8
0
 def __init__(self, log=1):
     json_data = open('config/config.json').read()
     data = loads(json_data)
     self.token = str(data['github_access_token'])
     self.params = {'access_token': self.token, 'per_page': 100}
     self.root_url = "https://api.github.com"
     self.options = {}
     self.options['log'] = log
     self.conn = db.connect()
     self.cursor = self.conn.cursor()
Example #9
0
def initValueByJob():
    # mycursor = mydb.cursor()
    conn = mysql.connect()
    mycursor = conn.cursor()
    mycursor.execute(
        "SELECT title, idcareer, salary, sex, category, position, diploma, experience, address, idpost FROM post"
    )
    jobs = mycursor.fetchall()
    for job in jobs:
        initJobVsCandidate(job)
Example #10
0
def search():
    from_location = request.args.get("from")
    in_location = request.args.get("in")
    cursor = mysql.connect().cursor()
    cursor.execute(
        'select population, region_name, country_name from cities where name="'
        + from_location + '"')
    from_info = cursor.fetchall()
    cursor.execute(
        'select population, region_name, country_name from cities where name="'
        + in_location + '"')
    in_info = cursor.fetchall()
    return from_location + ": " + str(
        from_info) + "<br>" + in_location + ": " + str(in_info)
Example #11
0
def login():
	email = request.form["emai[l"]
	password = request.form["password"]
	cursor = mysql.connect().cursor()
	cursor.execute("SELECT password FROM users WHERE email = \'" + email + "\'")
	temp = cursor.fetchall()
	if temp != None:
		truePassword = str(temp)[3:len(temp) - 3]
		if hashlib.md5(password).hexdigest() == truePassword:
			return "Success!!!!! here is the main page"
			#return render_template('MainPage.html')
		else:
			return "Username or Password was incorrect. Try again."
	else:
		return "Username or Password was incorrect. Try again."
Example #12
0
def retrieve_tables_and_columns():
    cursor = mysql.connect().cursor()
    cursor.execute("SHOW TABLES")
    tablenames = cursor.fetchall()
    complete_list = ""
    for i in xrange(len(tablenames)):
        cur_table = str(tablenames[i]).split("'")[1]
        complete_list += cur_table
        complete_list += ": "
        #cursor = mysql.connect().cursor()
        cursor.execute("DESCRIBE " + cur_table)
        cur_table_columns = cursor.fetchall()
        for j in cur_table_columns:
            complete_list += str(j[0]) + ", "
        complete_list += "<br \\><br \\>"
    return complete_list
Example #13
0
def selectForJob(idJob):
    # mycursor = mydb.cursor()
    conn = mysql.connect()
    mycursor = conn.cursor()
    sql = "SELECT idcandidate FROM job_candidate where idjob = %s order by score desc "
    mycursor.execute(sql, (idJob, ))
    results = mycursor.fetchall()
    listCandidate = []
    for candidate in results:
        mycursor.execute(
            "select idstudent,email, name, sex, address, birthday, phone, skill, experience, education, objective, photo, other, position, diploma, category, title, career, salary  from student where idstudent = %s",
            (candidate[0], ))
        row_headers = [x[0] for x in mycursor.description]
        datadict = mycursor.fetchone()
        data = dict(zip(row_headers, datadict))
        data["birthday"] = data["birthday"].isoformat()
        listCandidate.append(data)
    return listCandidate
Example #14
0
def selectForCandidate(idCandidate):
    # mycursor = mydb.cursor()
    conn = mysql.connect()
    mycursor = conn.cursor()
    sql = "SELECT idjob FROM job_candidate where idCandidate = %s order by score desc "
    mycursor.execute(sql, (idCandidate, ))
    results = mycursor.fetchall()
    json_data = []
    for job in results:
        mycursor.execute(
            "select idcompany, idpost,category,salary,address,created,expired,title,idcareer from post where idpost = %s",
            (job[0], ))
        row_headers = [x[0] for x in mycursor.description]
        datajob = mycursor.fetchone()
        data = dict(zip(row_headers, datajob))
        data["created"] = data["created"].isoformat()
        data["expired"] = data["expired"].isoformat()
        pprint(data)
        json_data.append(data)
    # res = json.dumps(json_data, ensure_ascii=False)
    return json_data
Example #15
0
def initJobVsCandidate(job):
    pprint(job)
    # mycursor = mydb.cursor()
    conn = mysql.connect()
    mycursor = conn.cursor()
    mycursor.execute(
        "SELECT title, career, salary, sex, category, position, diploma, experience, address, idstudent FROM student"
    )
    pprint(mycursor.description)
    candidates = mycursor.fetchall()
    for candidate in candidates:
        try:
            title = compare_title(candidate[0], job[0])
            career = compare_career(candidate[1], job[1])
            salary = compare_salary(candidate[2], job[2])
            sex = compare_sex(candidate[3], job[3])
            category = compare_category(candidate[4], job[4])
            position = compare_position(candidate[5], job[5])
            diploma = compare_diploma(candidate[6], job[6])
            experience = compare_experience(candidate[7], job[7])
            address = compare_address(candidate[8], job[8])
            score_val = score(title, career, salary, sex, category, position,
                              diploma, experience, address)
            if score_val > 0.8:
                try:
                    sql = "INSERT INTO job_candidate (idjob, idcandidate, score) VALUES (%s, %s,%s) ON DUPLICATE KEY UPDATE score = VALUES(score);"
                    mycursor.execute(sql, (job[9], candidate[9], score_val))
                    # mydb.commit()
                    conn.commit()

                except BaseException as e:
                    print('Statement:', e.args)
                    print('Type:', type(e))
                    print("Fail Insert!")

        except BaseException as e:
            print('Statement:', e.args)
            print('Type:', type(e))
            print("Data parsing failed!")
Example #16
0
def candidateVsPost(candidate):
    pprint(candidate)
    # mycursor = mydb.cursor()
    conn = mysql.connect()
    mycursor = conn.cursor()
    mycursor.execute(
        "SELECT title, idcareer, salary, sex, category, position, diploma, experience, address, idpost FROM post"
    )
    posts = mycursor.fetchall()
    for job in posts:
        try:
            title = compare_title(candidate["title"], job[0])
            career = compare_career(candidate["career"], job[1])
            salary = compare_salary(candidate["salary"], job[2])
            sex = compare_sex(candidate["sex"], job[3])
            category = compare_category(candidate["category"], job[4])
            position = compare_position(candidate["position"], job[5])
            diploma = compare_diploma(candidate["diploma"], job[6])
            experience = compare_experience(candidate["experience"], job[7])
            address = compare_address(candidate["address"], job[8])
            score_val = score(title, career, salary, sex, category, position,
                              diploma, experience, address)
            if score_val > 0.76:
                try:
                    sql = "INSERT INTO job_candidate (idjob, idcandidate, score) VALUES (%s, %s,%s) ON DUPLICATE KEY UPDATE score = VALUES(score);"
                    mycursor.execute(
                        sql, (job[9], candidate["idstudent"], score_val))
                    # mydb.commit()
                    conn.commit()
                except Exception as e:
                    print('Statement:', e.args)
                    print('Type:', type(e))
                    print("Fail Insert!")

        except Exception as e:
            print('Statement:', e.args)
            print('Type:', type(e))
            print("Data parsing failed!")
Example #17
0
def get():
    cursor = mysql.connect().cursor()
    cursor.execute("SHOW TABLES")
    tablenames = cursor.fetchall()
    return "tablenames: " + str(tablenames)
 def __init__(self):
     self.queue = redis_queue.connect()
     self.p = self.queue.pubsub()
     self.p.subscribe('newssource-channel')
     self.conn=mysql.connect()
     self.cursor = self.conn.cursor()