Created
December 7, 2016 20:38
-
-
Save waynr/42d008fb937b42628b60f2935c27843a to your computer and use it in GitHub Desktop.
sqlalchemy jenkins metrics db query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import datetime | |
from sqlalchemy import create_engine, MetaData, Table | |
from sqlalchemy.orm import sessionmaker | |
engine = create_engine('postgres://meow:[email protected]/jenkins_meow') | |
meta = MetaData(bind=engine) | |
jenkins_runs = Table("jenkins_details_run", meta, autoload=True, autoload_with=engine) | |
Session = sessionmaker(bind=engine) | |
session = Session() | |
today = datetime.date.today() | |
yesterday = today - datetime.timedelta(1) | |
for jr in session.query(jenkins_runs).filter_by(startdate=yesterday): | |
print(jr.jobname) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment