示例#1
0
文件: views.py 项目: dohyekim/PyWeb
def posting():
    title = db_session.query(Post).first()
    posts = db_session.query(Post).options(subqueryload(Post.user))
    return render_template('posting.htm',
                           title="Posting Page",
                           postTitle=title,
                           posts=posts)
示例#2
0
def myboards():
    loginUser = session.get('loginUser')
    userid = loginUser["userid"]
    board = json_boards()
    instrument = Instrument.query.all()
    boardtb = db_session.query(Board).filter(Board.user_id == userid).order_by(
        Board.board_id.desc())
    boardinst = db_session.query(BoardInstrument).join(
        Board, Board.board_id == BoardInstrument.board_id).filter(
            Board.user_id == userid)
    return jsonify({
        'boardinst': [t.json() for t in boardinst],
        'instruments': [i.json() for i in instrument],
        'boardtb': [b.json() for b in boardtb]
    })
示例#3
0
def sql2():
    try:
        ret = db_session.query(SongInfo).options(joinedload(
            SongInfo.album)).filter(SongInfo.likecnt < 10000)
    except SQLAlchemyError as sqlerr:
        db_session.rollback()
        print("SqlError>>", sqlerr)

    except:
        print("Error!!")

    finally:
        db_session.close()

    return render_template('main.html', ret=ret)
示例#4
0
文件: views.py 项目: gouwon/LogForYou
def log():

    utype = session['loginUser']['utype']
    if (utype):
        return redirect('/login')
    uid = session['loginUser']["userid"]

    # petient column information
    ret = db_session.query(UsercolMaster).join(
        Pat_Usercol, UsercolMaster.id == Pat_Usercol.usercol_id).join(
            Patient, Patient.id == Pat_Usercol.doc_pat_id).filter(
                Patient.id == uid).all()

    return render_template("log.html",
                           uname=session['loginUser']["name"],
                           ucol=ret)
示例#5
0
文件: views.py 项目: dohyekim/PyWeb
def post(postid):
    postno = db_session.query(Post).options(subqueryload(
        Post.user)).filter(Post.postid == postid).first()
    return render_template('postdetail.htm', title=postno.title, postno=postno)
示例#6
0
文件: views.py 项目: gouwon/LogForYou
def insert_data(v):
    item = db_session.query(Table).filter_by(code=v['code']).first()
    if item == None:
        data = Table(v['code'], v['data'])
        db_session.add(data)
        db_session.commit()
示例#7
0
文件: tests.py 项目: dohyekim/PyWeb
def sql3():
    res = db_session.query(Album).options(subqueryload(Album.songs))

    return render_template('sqltest.htm', title="sql test (n:1)", res=res)
示例#8
0
文件: tests.py 项目: dohyekim/PyWeb
def sql2():
    res = db_session.query(Song).options(subqueryload(
        Song.album)).filter(Song.genre == "Ballad")
    return render_template('sqltest.htm', title="sql test(join)", res=res)
示例#9
0
文件: tests.py 项目: dohyekim/PyWeb
def sql4():
    res = db_session.query(Song).options(subqueryload(Song.songsinger))
    # ret = db_session.query(Singer).options(subqueryload(Singer.songsinger))

    return render_template('sqltest.htm', title="sql test (n:n) ", res=res)
示例#10
0
文件: tests.py 项目: dohyekim/PyWeb
def sql2():
    res = db_session.query(Song).options(subqueryload(
        Song.album)).filter_by(genre="Ballad").options(
            subqueryload(Song.songsinger, SongSinger.singer))
    return render_template('sqltest.htm', title="sql test(join)", res=res)