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)
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] })
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)
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)
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)
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()
def sql3(): res = db_session.query(Album).options(subqueryload(Album.songs)) return render_template('sqltest.htm', title="sql test (n:1)", res=res)
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)
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)
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)