Spaces:
Sleeping
Sleeping
File size: 1,133 Bytes
4cd0338 33d57b4 4cd0338 33d57b4 4cd0338 33d57b4 4cd0338 33d57b4 4cd0338 33d57b4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
from pymongo import MongoClient
import socket
from dotenv import load_dotenv
import os
import urllib
import streamlit as st
load_dotenv()
def mongodb_push_data(company_name_to_symbol, number_of_symbols):
username = urllib.parse.quote_plus(os.environ.get("USERNAME"))
password = urllib.parse.quote_plus(os.environ.get("PASSWORD"))
# client = "mongodb+srv://bhanuprasanna:<password>@capiport.xtnx5it.mongodb.net/"
MONGO_DB_URI = "mongodb+srv://%s:%s@capiport.xtnx5it.mongodb.net/" % (
username,
password,
)
st.write(MONGO_DB_URI)
# client = MongoClient(MONGO_DB_URI)
# if "capiport" in client.list_database_names():
# db = client["capiport"]
# else:
# db = client["capiport"]
# collection = db["stocks they picked"]
# hostname = socket.gethostname()
# ip_address = socket.gethostbyname(hostname)
# data = {
# "hostname": hostname,
# "stocks_picked": company_name_to_symbol,
# "number_of_stocks_picked": number_of_symbols,
# "ip_address": ip_address,
# }
# collection.insert_one(data)
# client.close()
|