Send data
Tags: #mongodb #database #naas_drivers #snippet
Author: Florent Ravenel

Input

Import library

1
from naas_drivers import mongo
2
import pandas as pd
Copied!

Variables

1
# Credentials
2
user = "my user"
3
passwd = "my passwd"
4
host = "url"
5
port = 9090
6
7
# DB parameters
8
collection_name = "col"
9
db_name = "db_name"
Copied!

Model

Read dataframe

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

Output

Send data

1
mongo.connect(host, port, user, passwd).send(df, collection_name, db_name, replace=False)
Copied!
Copy link
Edit on GitHub