Skip to content

Instantly share code, notes, and snippets.

@0xa
Created August 14, 2015 17:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0xa/560a3bc5dff50a18c875 to your computer and use it in GitHub Desktop.
Save 0xa/560a3bc5dff50a18c875 to your computer and use it in GitHub Desktop.
select_c = DBSession.query(VPNSession,
VPNSession.connect_date.label('ev_date'),
sae.literal_column("'c'").label('ev_type')) \
.order_by(VPNSession.connect_date.desc()) \
.limit(10)
select_d = DBSession.query(VPNSession,
VPNSession.disconnect_date.label('ev_date'),
sae.literal_column("'d'").label('ev_type')) \
.filter(VPNSession.disconnect_date != None) \
.order_by(VPNSession.disconnect_date.desc()) \
.limit(10)
results = select_c.union(select_d).order_by('ev_date desc').all()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment