Пример #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