示例#1
0
def relationByFollowingIdAndFollowerId(following_id, follower_id):
    cursor.execute(
        'SELECT * FROM relation WHERE following_id = %s AND follower_id = %s',
        (
            following_id,
            follower_id,
        ))
    r = cursor.fetchone()
    return r
示例#2
0
def userIdByEmailPassword(email, password):
    cursor.execute(
        "SELECT user_id FROM users WHERE email = %s AND password = crypt(%s, password);",
        (
            email,
            password,
        ))
    u = cursor.fetchone()
    if u is None:
        return None
    return u
示例#3
0
def userFollow(following_id, follower_id):
    cursor.execute(
        'SELECT * FROM relation WHERE following_id = %s AND follower_id = %s',
        (following_id, follower_id))
    if cursor.fetchone() is None and following_id != follower_id:
        c_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
        cursor.execute(
            "INSERT INTO relation(following_id, follower_id, c_time) VALUES(%s,%s,%s);",
            (following_id, follower_id, c_time))
        conn.commit()
        cursor.execute("SELECT nickname FROM users WHERE user_id = %s;",
                       (following_id, ))
    return ""
示例#4
0
def userByEmail(email):
    cursor.execute("SELECT * FROM users where email = %s;", (email, ))
    u = cursor.fetchone()
    return u
示例#5
0
def userByUserId(user_id):
    cursor.execute("SELECT * FROM users where user_id = %s;", (user_id, ))
    u = cursor.fetchone()
    return u
示例#6
0
def likeMsgCountLike(msg_id):
    cursor.execute("SELECT COUNT(*) AS count FROM like_msg where msg_id = %s;",
                   (msg_id, ))
    like_num = cursor.fetchone()
    return like_num['count']
示例#7
0
def likeMsgCount():
    cursor.execute("SELECT COUNT(*) AS count FROM like_msg")
    nb = cursor.fetchone()
    if nb is None:
        return 0
    return nb['count']
示例#8
0
def messageCount():
    cursor.execute("SELECT COUNT(*) AS count FROM message")
    nb = cursor.fetchone()
    if nb is None:
        return 0
    return nb['count']
示例#9
0
def likeCmtCountLike(cmt_id):
    cursor.execute("SELECT COUNT(*) AS count FROM like_cmt where cmt_id = %s;",
                   (cmt_id, ))
    like_num = cursor.fetchone()
    return like_num['count']
示例#10
0
def likeCmtGetOne(cmt_id, user_id):
    cursor.execute("SELECT * FROM like_cmt where cmt_id = %s AND user_id = %s",
                   (cmt_id, user_id))
    like = cursor.fetchone()
    return like
示例#11
0
def CommentCountCmt(msg_id):
    cursor.execute("SELECT COUNT(*) AS count FROM comment where msg_id = %s;",
                   (msg_id, ))
    like_num = cursor.fetchone()
    return like_num['count']
示例#12
0
def commentCount():
    cursor.execute("SELECT COUNT(*) AS count FROM comment")
    nb = cursor.fetchone()
    if nb is None:
        return 0
    return nb['count']
示例#13
0
def commentByCmtId(cmt_id):
    cursor.execute("SELECT * FROM comment where cmt_id = %s;", (cmt_id, ))
    cmt = cursor.fetchone()
    return cmt
示例#14
0
def userByNickname(nickname):
    cursor.execute("SELECT * FROM users where nickname = %s;", (nickname, ))
    u = cursor.fetchone()
    return u
示例#15
0
def likeMsgGetOne(msg_id, user_id):
    cursor.execute("SELECT * FROM like_msg where msg_id = %s AND user_id = %s",
                   (msg_id, user_id))
    like = cursor.fetchone()
    return like
示例#16
0
def countcmt(msg_id):
    cursor.execute("SELECT COUNT(*) FROM comment where msg_id = %s;",
                   (msg_id, ))
    like_num = cursor.fetchone()
    return like_num[0]
示例#17
0
def messageById(msg_id):
    cursor.execute("SELECT * FROM message where msg_id = %s;", (msg_id, ))
    m = cursor.fetchone()
    return m