see on GitHub

Session: Opening a session

To open synchronous session use open_session method from documentstore.

Syntax

# Open session for a 'default' database configured in 'documentstore'
with store.open_session() as session:
    session.load("doc/1")
    # code here

# Open session for a specific database
with store.open_session(database="Your database") as session:
    session.load("doc/2")
    # code here

# Open session for a specific database with api_key
with store.open_session(database="Your database", api_key="API_KEY") as session:
    session.load("doc/3")
    # code here
Parameters
database str The name of the database (default value is None)
api_key str The api_key for the database (default value is None)
force_read_from_master bool If set to true force the database to always read from primary database in replication (default value is False)
Return Value
documentsession Implements Unit of Work for accessing the RavenDB server

Remarks

with statement can be used when open a session