def addResume(resume):

    try:
        res = 0
        connect = creatConnect()
        cursor = connect.cursor()

        sql="insert into resume_basic(resume_title,name,sex,birth_date,advantage,high_education,work_years,position_now,user_id)" \
            "VALUES('{0}','{1}',{2},'{3}','{4}','{5}',{6},{7},{8})"\
            .format(resume['title'],resume['name'],resume['sex'],resume['bitrh'],resume['adv'],resume['edu'],resume['work'],resume['positon'],resume['user_id'])

        res = cursor.execute(sql)

        resume_id = connect.insert_id()

        sql_job='insert into resume_education(school_name,major,education,begin_date,end_date,resume_basic_id)' \
                'values("北京大学","计算机","博士","2010-1-1","2014-3-1",{0})'.format(resume_id)

        res += cursor.execute(sql_job)
        print(resume_id)

        connect.commit()

    except Exception as ex:
        print(ex)
        connect.rollback()
        return 0
    finally:
        if cursor:
            cursor.close()
        if connect:
            connect.close()
    return res
Exemplo n.º 2
0
def getAllUser():

    try:
        res = 0
        connect = creatConnect()
        # 返回结果不是元组,而是字典
        cursor = connect.cursor(cursor=pymysql.cursors.DictCursor)

        sql = "select * from user"

        cursor.execute(sql)

        user1 = cursor.fetchone()
        print(user1)

        cursor.fetchone()
        cursor.fetchone()

        cursor.scroll(1, mode='absolute')
        user2 = cursor.fetchone()
        print(user2)

    except Exception as ex:
        print(ex)

        return 0
    finally:
        if cursor:
            cursor.close()
        if connect:
            connect.close()
    return res
Exemplo n.º 3
0
def getPosition(condition):

    try:
        res = 0
        connect = creatConnect()
        # 返回结果不是元组,而是字典
        cursor = connect.cursor(cursor=pymysql.cursors.DictCursor)

        sql = "select * from position_info where name like '%{0}%' or profession_name like '%{0}%'".format(
            condition)

        cursor.execute(sql)

        users = cursor.fetchall()
        print(users)
    except Exception as ex:
        print(ex)

        return 0
    finally:
        if cursor:
            cursor.close()
        if connect:
            connect.close()
    return res


# getPosition('金融')
def getCityId(cname):

    try:
        res=0
        connect=creatConnect()
        # 返回结果不是元组,而是字典
        cursor = connect.cursor(cursor=pymysql.cursors.DictCursor)

        sql="call getUsersByCity('{0}',@aa); ".format(cname)

        cursor.execute(sql)


        a=cursor.fetchall()
        print(a)
    except Exception as ex:
        print(ex)

        return 0
    finally:
        if cursor:
            cursor.close()
        if connect:
            connect.close()
    return res
def addUser(user):

    try:
        res = 0
        connect = creatConnect()
        cursor = connect.cursor()
        sql="insert into user(telephone,password,email,regist_date) values('{0}','{1}','{2}',CURDATE())"\
            .format(user['tel'],user['password'],user['email'])
        res = cursor.execute(sql)
        connect.commit()

    except Exception as ex:
        print(ex)
        return 0
    finally:
        if cursor:
            cursor.close()
        if connect:
            connect.close()
    return res