示例#1
0
def add_post_for(username, image_url, thumb_url):
    '''保存图片对应的用户信息和存储信息'''
    user = session.query(User).filter_by(name=username).first()
    post = Post(image_url=image_url, user=user, thumb_url=thumb_url)
    session.add(post)
    session.commit()
    return post.id
示例#2
0
def login(username):
    '''查询'''
    t = datetime.now()
    print('user:{}login at {} '.format(username,t))

    session.query(User).filter_by(name=username).update({User.last_login})
    session.commit()
示例#3
0
def add_post_for(username, image_url, thumb_url):
    """
    保存特定用户的图片
    """
    user = session.query(User).filter_by(name=username).first()
    post = Post(image_url=image_url, thumb_url=thumb_url, user=user)
    session.add(post)
    session.commit()
示例#4
0
def login(username):
    """
    记录用户登入时间, 并保存的数据库的last_login
    """
    t = datetime.now()
    print("user: {} login at {}".format(username, t))
    user_query = session.query(User).filter_by(name=username)
    session.query(User).filter_by(name=username).update({User.last_login: t})
    session.commit()
示例#5
0
def add_post_for(username, image_url, thumb_url):
    '''
    保存特定用户的图片
    :param username:用户名
    :param image_url:上传图片的保存地址(static下的)
    :param thumb_url:缩略图的保存地址(static下的)
    :return:
    '''
    user = session.query(User).filter_by(name=username).first()
    post = Post(image_url=image_url, thumb_url=thumb_url, user=user)
    session.add(post)
    session.commit()
    return post.id
def add_post_for(username, img_url, thumb_url):
    """
    posts表增加数据
    :param username:
    :param img_url:
    :param thumb_url:
    :return:
    """
    user = User.query(username)
    post = Post(img_url=img_url, user=user, thumb_url=thumb_url)
    session.add(post)
    session.commit()
    return post
示例#7
0
def add_post_for(username, image_url, thumb_url):
    """
    保存用户上传的图片信息.
    :param username:
    :param image_url:
    :param thumb_url:
    :return:
    """

    user = session.query(User).filter_by(name=username).first()
    post = Post(image_url=image_url, thumb_url=thumb_url, user=user)
    session.add(post)
    session.commit()
    return post