GithubHelp home page GithubHelp logo

mortafix / streamlit-mongo Goto Github PK

View Code? Open in Web Editor NEW
6.0 1.0 1.0 464 KB

Streamlit MongoDB Connector: An efficient connector for interfacing MongoDB with Streamlit apps, developed for the Streamlit Connections Hackathon.

Home Page: https://mongo-connector.streamlit.app

License: MIT License

Python 100.00%
mongodb streamlit

streamlit-mongo's Introduction

Open in Streamlit PyPI Code style: black

Streamlit MongoDB Connector

This repository contains the source code for a MongoDB connector developed for the Streamlit Connections Hackathon.
The goal of this project is to showcase how to leverage the power of Streamlit's new st.connection feature to connect Streamlit applications with MongoDB databases, and use this connection in practical applications.

Installation & Usage

The package can be installed via PyPi.

pip3 install st_mongo_connection

and the following is a simple example to use it

import streamlit as st
from st_mongo_connection import MongoDBConnection

connection = st.connection("mongodb", type=MongoDBConnection)
st.help(connection)
# secrets.toml
[connections.mongodb]
url="mongodb+srv://<username>:<password>@<cluster-name>.<cluster-id>.mongodb.net"
database="database-name"
collection="collection-name"

If you want a real example and a detailed implemetation check out the streamlit app.

Overview

The application is divided into three main sections:

  1. Connection Demonstration: Shows how the connection to MongoDB has been implemented, demonstrating how data can be retrieved and manipulated.

  2. MongoDB Configuration: Demonstrates how to configure the MongoDB connection, explaining how to set it up via the secrets.toml file or directly through the st.connection call.

  3. StreamY: A prototype for a simple text-based social network, where users can post texts on a wall. This showcases the MongoDB connection's use in a practical application, as it's used to store and retrieve posts.

About me

Hello! I'm Moris, a Computer Science Master's graduate with extensive experience in Streamlit and MongoDB. I've developed the MagicLit framework to serve as the base for my company's management app.
I participated in this hackathon to create an optimal component for connecting MongoDB to Streamlit. I hope this project will contribute to the Streamlit community and assist other developers.

streamlit-mongo's People

Contributors

mortafix avatar

Stargazers

Ankit Basare avatar  avatar Mario Cordeiro Jr avatar Chak Hang Chan avatar 言辰寸心 avatar  avatar

Watchers

 avatar

Forkers

robcwu

streamlit-mongo's Issues

Issue with secrets toml

Hello !

Thanks for your package.

It seems to have a bug with the secrets part. I'm doing a very simple connection with my mongodb cluster.

Error :
KeyError: 'st.secrets has no key "type". Did you forget to add it to secrets.toml or the app settings on Streamlit Cloud? More info: https://docs.streamlit.io/streamlit-cloud/get-started/deploy-an-app/connect-to-data-sources/secrets-management'
Traceback:
File "C:\Users\aurel\AppData\Local\Programs\Python\Python39\lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 534, in _run_script
exec(code, module.dict)
File "C:\Users\aurel\OneDrive - De Vinci\ONE DRIVE PC\A5\Structure données cloud\Livrable4\appV2.py", line 4, in
conn = st.connection(
File "C:\Users\aurel\AppData\Local\Programs\Python\Python39\lib\site-packages\streamlit\runtime\connection_factory.py", line 300, in connection_factory
type = secrets_singleton["connections"][name]["type"]
File "C:\Users\aurel\AppData\Local\Programs\Python\Python39\lib\site-packages\streamlit\runtime\secrets.py", line 92, in getitem
raise KeyError(_missing_key_error_message(key))

Any clue ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.