# MongoDB

Phiona can connect to your MongoDB collections, import tables from your collections, and write back transformed tables into your collection. To set up your MongoDB connection, click on Add New Data Source in your Project page, and then click the MongoDB button.

![Click on the MongoDB button to connect your clusters](/files/-MfYMHMuKGj2SOWZbq79)

Click on the Create a New Connection link at the top right of the menu, and you'll be prompted to fill in a few details about your MongoDB connection.

![Configure your MongoDB connection](/files/-MfZ5B1XByP8Azo_ZnU2)

As part of the connection set up, you'll need to enter a name for your connection, the connection string from Mongo, and the specific database collection that you would like to connect to.

To find your MongoDB connection string, you'll need to go into your MongoDB Clusters screen, and select the "Connect" button under the cluster that you would like to connect to.

![Connect in MongoDB](/files/-MfZ5TSMxhpm4xwayUyJ)

A screen will pop up. Select the Connect via Application option highlighted below.

![Select "Connect your application"](/files/-MfZ5hb-WVXSkz_97_dG)

Next, you'll see a screen where there's a dropdown on driver / version and a connection string.

![Select the Python Driver and copy your string](/files/-MfZ5trv4ybhXK2ltE1S)

Select the Python Version 3.1.1 or later option, and then copy the connection string from the MongoDB screen into Phiona. To find your database name, go back to your main clusters screen, and select "Collections" to see your collection databases.

![Select Collections to find your database name](/files/-MfZ6775L_ywqxgHptRM)

Remember the database name that you would like to import, and enter the database name as a replacement to \<dbname> into the connection string in Phiona. If you have a read/write password for MongoDB, then replace those values into the connection strings as well. After you have all of your information entered into Phiona, save the connection.

To connect to your MongoDB collections, you must enable connections from any IP address into your database (for security, it will still require knowing your username, password, and specific database name). Many Phiona users create separate User IDs for the Phiona application, rather than storing their admin credentials in multiple places- we would suggest this as a security best practice.

If you require an extra measure of security, you can set up VPC Peering for your MongoDB connections, the instructions are located here: <https://docs.atlas.mongodb.com/security-vpc-peering>. Please reach out to us at <support@phiona.com> for additional detail.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.phiona.com/data-sources/mongodb.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
