• AIPressRoom
  • Posts
  • Streamlit and MongoDB: Storing Your Knowledge within the Cloud | by Alan Jones | Aug, 2023

Streamlit and MongoDB: Storing Your Knowledge within the Cloud | by Alan Jones | Aug, 2023

Streamlit enables you to deploy your public apps to their cloud free of charge, however any recordsdata or databases you create domestically will stop to exist when the app finishes. This will not be the behaviour that you really want, so we’re going to discover an answer utilizing MongoDB.

For a lot of apps shedding this information isn’t any downside. For instance, in case you have designed a dashboard that reads information from an exterior supply any information that you just generate is prone to be non permanent and solely wanted whereas the app is working.

However, as I famous when creating my app for the article, Simple Surveys with Streamlit, if the app itself is producing information that must be saved, it’s not so simple. In that app, I saved the info in a neighborhood file however in a cloud-based deployment these will stop to exist when the app stops working — the correct answer is to make use of an exterior information retailer.

We’re going to see how we will obtain this with MongoDB, however there are alternate options.

What are the alternatives?

Within the Streamlit documentation, there are guides for connecting to varied databases and cloud storage suppliers. They principally break down into three areas: information buckets resembling AWS S3 and Google Cloud Storage, the place you possibly can retailer something; SQL databases like Microsoft’s SQL Server, MySQL, PostgreSQL; and NoSQL databases of which Firestore and MongoDB are examples. For every sort, you clearly want entry to a server that hosts that individual database.

To be completely sincere, I’m not the largest fan of SQL. It appears to me that there’s a disjoint between SQL code and Python that feels uncomfortable. (Having stated that I undoubtedly recognize the ability and comfort of SQL and have written about it here, here and here.)

However, NoSQL databases like MongoDB really feel like they match extra neatly into the Python manner of doing issues.

I’m positive there are all kinds of arguments about pace, effectivity, ease of use, safety and I don’t know what else. However I’m not going there…