Skip to content

Latest commit

 

History

History
54 lines (35 loc) · 1.61 KB

File metadata and controls

54 lines (35 loc) · 1.61 KB



Template request | Bug report | Generate Data Product

Tags: #mongodb #database #naas_drivers #snippet #operations #naas

Author: Florent Ravenel

Description: This notebook provides instructions on how to send data to a MongoDB database.

Input

Import library

from naas_drivers import mongo
import pandas as pd

Variables

# Credentials
user = "my user"
passwd = "my passwd"
host = "url"
port = 9090

# DB parameters
collection_name = "col"
db_name = "db_name"

Model

Read dataframe

data = {"LABEL": "Label 1", "VALUE": 0}
df = pd.DataFrame([data])
df

Output

Send data

mongo.connect(host, port, user, passwd).send(
    df, collection_name, db_name, replace=False
)