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?