Links

Send data

Tags: #mongodb #database #naas_drivers #snippet #operations #naas
Author: Florent Ravenel

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)