From d132b0e6c97ee84e1583ad549e8a1b48003f0352 Mon Sep 17 00:00:00 2001 From: Austin Clark Date: Thu, 6 Aug 2015 05:25:08 -0600 Subject: [PATCH] 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 --- doc/source/api.rst | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/doc/source/api.rst b/doc/source/api.rst index 2612623..b6632db 100644 --- a/doc/source/api.rst +++ b/doc/source/api.rst @@ -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 `````````````````````````````````````````````