如何在SQLAlchemy上打印标签

时间:2013-01-28 02:11:12

标签: sqlalchemy

尝试让use_labels=True在下面的查询中工作......但是库会出现随机错误....我正在进行这种复杂的连接,需要查看列上的标签以尝试抓取数据。我知道我不应该使用ORM会话execute(),但坦率地说,idc在这一点上,只是想让它工作。我放弃了ORM ...不能使用下面的查询:

data = DBSession.execute(text("SELECT \
                        * \
                        FROM \
                        art_packs \
                        LEFT OUTER JOIN \
                        art_pack_pieces AS art_pack_pieces_1 ON art_packs.art_pack_id = art_pack_pieces_1.art_pack_id \
                        LEFT OUTER JOIN \
                        art_pack_pieces_artists AS art_pack_pieces_artists_1 ON art_pack_pieces_1.art_pack_piece_id = art_pack_pieces_artists_1.art_pack_piece_id \
                        LEFT OUTER JOIN \
                        users ON art_pack_pieces_artists_1.artist_id = users.id \
                        LEFT OUTER JOIN \
                        art_pack_pieces as art_pack_pieces_2 ON art_packs.cover_id = art_pack_pieces_2.art_pack_piece_id \
                        LEFT OUTER JOIN \
                        art_pack_pieces_likes as art_pack_pieces_likes_1 ON art_pack_pieces_1.art_pack_piece_id = art_pack_pieces_likes_1.art_pack_piece_id AND art_pack_pieces_likes_1.artist_id = " + str(artistID) + " \
                        WHERE art_packs.art_pack_id = " + id, use_labels=True)).fetchall()

查询不是最安全的..但是int已经过验证,所以我想做的事情并没有错。

感谢。

0 个答案:

没有答案