# MongoDB Writer Lite (PyMongo Writer)

The PyMongo writer component is designed to write the data in the Mongo collection. It is a docker based component.

All component configurations are classified broadly into the following sections:

* ​[​Basic Information​](/data-pipeline-6/components/component-base-configuration.md)​
* Meta Information
* ​[Resource Configuration​](/data-pipeline-6/components/resource-configuration.md)​
* ​[Connection Validation](https://docs.bdb.ai/7.6/data-pipeline/components/connection-validation)​

{% hint style="success" %}
*Please follow the demonstration to configure the component.*
{% endhint %}

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fc39ZvXI46qjXzpN3rYAg%2Fuploads%2FPcT4pwTBzMdbmg7L3aE4%2Fmongo%20writer%20lite.mp4?alt=media&token=277d0049-24fe-4c99-af1a-dd9fb980f09d>" %}
MongoDB Writer Lite
{% endembed %}

## **Configuration Steps for PyMongo Writer** (Mongodb Writer Lite)**:**&#x20;

The PyMongo Writer writes the data to the Mongo Database.

* Drag & drop the PyMongo Writer component to the Pipeline Workflow Editor.

<figure><img src="/files/rVMu1MaKj7HA9mjafsoD" alt=""><figcaption></figcaption></figure>

* Click the dragged PyMongo Writer component to open the component properties tabs below.

### Basic Information Tab

It is the default tab to open for the PyMongo Writer while configuring the component.

* Select an Invocation type from the drop-down menu to confirm the running mode of the reader component. Select ‘**Real-Time**’ or ‘**Batch**’ from the drop-down menu.
* **Deployment Type:** It displays the deployment type for the component. This field comes preselected.
* **Container Image Version:** It displays the image version for the docker container. This field comes pre-selected.
* **Failover Event:** Select a failover Event from the drop-down menu.
* **Batch Size:** Provide the maximum number of records to be processed in one execution cycle.

<figure><img src="/files/qJfA73PinB7PIZ0Xzqnn" alt=""><figcaption><p>Basic Information Tab</p></figcaption></figure>

### Meta Information Tab

Open the ***Meta Information*** tab and configure all the connection-specific details for the PyMongo Writer.

* **Connection Type:** Select either of the options out of ‘**Standard**’, ‘**SRV**’, and ‘**Connection String**’ connection types.
* **Port number**(\*): Provide the Port number (It appears only with the ‘Standard’ connection type).
* **Host IP Address**(\*): IP address of the host.
* **Username**(\*): Provide username.
* **Password**(\*): Provide a valid password to access the MongoDB.
* **Database Name**(\*): Provide the name of the database where you wish to write data.
* **Collection Name** (\*): Provide the name of the collection.
* **Save Mode**: Select an option from the drop-down menu (the supported options are Upsert and Append).
* **Enable SSL:** Check-in this box to enable SSL feature for PyMongo writer.&#x20;

{% hint style="info" %}
*<mark style="color:green;">Please Note:</mark>* *<mark style="color:red;">Credentials will be different if this option is enabled</mark>*.
{% endhint %}

* **Composite Keys** (\*): This field appears only when the selected save mode is ‘Upsert’. The user can enter multiple composite keys separated by commas on which the 'Upsert' operation has to be done.
* **Additional Parameters:** Provide details of the additional parameters.
* **Connection String** (\*): Provide a connection string.

<figure><img src="/files/FE0hTxiexuyRAL2thcdf" alt=""><figcaption></figcaption></figure>

The ***Meta Information fields vary*** based on the selected ***Connection Type*** option.

* [x] Meta Information Tab with ***Standard*** as the Connection Type.

<figure><img src="/files/aIgIwD05xFLJ1gs9uGYy" alt=""><figcaption></figcaption></figure>

* [x] Meta Information Tab with ***SRV*** as the Connection Type.

<figure><img src="/files/9fqPvfgr1fHydoAaZ6qI" alt=""><figcaption></figcaption></figure>

* [x] Meta Information Tab with ***Connection String*** as the Connection Type.

<figure><img src="/files/UyBmmDneBl9yjnpEUn4G" alt=""><figcaption></figcaption></figure>

### Selected Columns

The users can select some specific columns to change the column name or data type while writing it to the collection. Users have to type the name of the column in the name field that has to be modified. If you went to change the name of the column, then put the name of your choice in the alias name section otherwise keep it the same as of column name. Then select the Column Type from the drop-down menu into which you want to change the datatype of that particular column. Once this is done, while writing the selected column data type and column name will be converted to your given choice.

&#x20;or

Use the ***Download Data*** and ***Upload File*** options to select the desired columns.

1. ***Upload File***: The user can upload the existing system files (CSV, JSON) using the ***Upload File*** icon (file size must be less than 2 MB).
2. ***Download Data (Schema):*** Users can download the schema structure in JSON format by using the ***Download Data*** icon.

<figure><img src="/files/N15ylM7yC7NjpKbDnYgL" alt=""><figcaption></figcaption></figure>

### Saving the Component Configuration

* Click the ***Save Component in Storage*** icon for the PyMongo Writer component.
* A message appears to notify the successful update of the component.

&#x20;  ![](https://859511478-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGDmsjfjJBNqow7Fo97cO%2Fuploads%2FMLJXCODWZ89gl5D2BUIb%2Fimage.png?alt=media\&token=cbb49163-eee2-45fe-871c-8c968086a31a)

* Click on the ***Activate Pipeline*** icon.&#x20;
* The pipeline will be activated and the **PyMongo writer** component will write the in-event data to the given MongoDB collection.


---

# 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.bdb.ai/data-pipeline-6/components/writers/mongodb-writers/mongodb-writer-lite-pymongo-writer.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.
