Hello community,
Today, I want to make an app that can be connected to mongodb. Using streamlit, I want to make a GUI for CRUD system. This is what I do so far
%%writefile app.py
import streamlit as st
import pymongo
from pymongo import MongoClient
import pandas as pd
import numpy as npst.header(âImport Well Log into MongoDB Serverâ)
mongoClient = MongoClient (âmongodb://localhost:27017/â)
database_names = mongoClient.list_database_names()
optmongo = st.selectbox(âChoose the databaseâ,(database_names))my_db2 = mongoClient[optmongo]
collection_list = my_db2.list_collection_names()
optmongo2 = st.selectbox(âChoose the collectionâ,(collection_list))
my_cols2 = my_db2[optmongo2]listwell2 = my_cols2.distinct(â#WELLâ)
#delete document
col1, col2 = st.columns(2)
with col1:
optionsremove = st.multiselect(âChoose the name of the well you wanted to remove from serverâ, listwell2)
remove = st.button(âRemoveâ)
if remove:
result = my_cols2.delete_many({â#WELLâ:optionsremove})
print('delete count: ', result.deleted_count)
The problem is, when I click the button âremoveâ, the document is still there, Did I do something wrong here?