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 with request_executor
request_executor = RequestsExecutor(database_name="Your database", certificate=None)
with DocumentStore.open_session(request_executor=request_executor) as session:
    session.load("doc/3")
    # code here
Parameters
database str The name of the database (default value is None)
requests_executor RequestsExecutor The requests executor (default value is None)
Return Value
DocumentSession Implements Unit of Work for accessing the RavenDB server

Remarks

with statement can be used when open a session