Wrapper around a MongoDB database.
MongoDBDatabase(
self,
client: MongoClient,
database: str,
schema: Optional[str] = None,
ignore_collections: Optional[List[str]] = None,
include_collections: Optional[List[str]] = None,
sample_docs_in_collection_info: int = 3,
indexes_in_collection_info: bool = False
)Construct a MongoDBDatabase from URI.
Close the resources used by the MongoDBDatabase.
Get names of collections available.
Get information about specified collections.
Follows best practices as specified in: Rajkumar et al, 2022 (https://arxiv.org/abs/2204.00498)
If sample_rows_in_collection_info, the specified number of sample rows will be
appended to each collection description. This can increase performance as
demonstrated in the paper.
Execute a MongoDB aggregation command and return a string representing the results.
If the statement returns documents, a string of the results is returned. If the statement returns no documents, an empty string is returned.
The command MUST be of the form: db.collectionName.aggregate(...).
Get information about specified collections.
Follows best practices as specified in: Rajkumar et al, 2022 (https://arxiv.org/abs/2204.00498)
If sample_rows_in_collection_info, the specified number of sample rows will be
appended to each collection description. This can increase performance as
demonstrated in the paper.
Execute a MongoDB command and return a string representing the results.
If the statement returns rows, a string of the results is returned. If the statement returns no rows, an empty string is returned.
If the statement throws an error, the error message is returned.
Return db context that you may want in agent prompt.