You are currently browsing legacy 4.1 version of documentation. Click here to switch to the newest 5.1 version.

We can help you with migration to the latest RavenDB

Contact Us Now
see on GitHub

Session: Opening a session

To open synchronous session use open_session method from documentstore.


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

# Open session for a specific database
with store.open_session(database="Your database") as session:
    # 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:
    # code here
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


with statement can be used when open a session