Update API docs to include alternative db layer initialization

Adds another usage method in 'Example usage patterns' that shows
how to initialize a db layer client without oslo.config. This is done
by creating a sqlalchemy engine with the appropriate db address and
then creating a session that will be directly passed to api methods.

Change-Id: Id01bb528b5357bcc4758c9fa7859778db527e0d3
This commit is contained in:
Austin Clark 2015-08-06 05:25:08 -06:00
parent c7f1df0962
commit d132b0e6c9

View File

@ -43,6 +43,23 @@ specify these options and just pass that config file into subunit2sql::
The tradeoff here is that you have to have a file available to configure
subunit2sql.
Another alternative is to initialize a sqlalchemy engine to create a session
with the appropriate db url. This session can then be passed to all API calls
without having to deal with oslo.config::
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
# Create engine with db url for session generation
engine=create_engine('mysql://subunit:subunit@localhost/subunit')
Session = sessionmaker(bind=engine)
# Create a new session to pass to API calls
# EX: api.get_run_metadata(session=session)
session = Session()
Parsing subunit stream and storing it in a DB
`````````````````````````````````````````````