Build/Database: Difference between revisions

Line 25: Line 25:
* Use the session to query the various tables.
* Use the session to query the various tables.
* Close the session when done
* Close the session when done
    import model
    # Connect to database called 'buildbot' on localhost, using
    # 'buildbot', 'passw0rd' as the username, password
    session_maker = model.connect("mysql://buildbot:passw0rd@localhost/buildbot")
    session = session_maker()
    try:
        builds = session.query(model.Build).filter_by(result=0)
        for build in builds:
            # Do something with build
    finally:
        # Close the session.  This cleans up cached objects, and frees the
        # connection to the database so it can be used by another session
        session.close()


=== Hooks ===
=== Hooks ===
Confirmed users
2,456

edits