Hey guys! I canāt get, how to establish connection to my local My SQL database using st.experimental_connection() from my cloud app by getting user inputā¦
This we would save things in secrets and handle without any credentials if we need to establish connection to our own MySQL server but what if I need to give access to user so that they can input their credentials and establish conn to their own local MySQL server?
1 Like
I have tried item assignment to secrets dict as well but not so surprisingly I got a type error saying secrets donāt support item assignment
Hi @Nirmal_Kumar,
Thanks for posting!
Do you have some code snippets or repo to share for the community to troubleshoot?
I think this could pose a security challenge for the users to enter their credentials to their db on your site unless youāve implemented some robust encryption.
If itās just for testing/dev, maybe add code to check if secrets exist, and if not, then ask the user to enter and pass it back to the connection.
Once you share more details and example code, then we can probe it better.
I havenāt made any code on that lines, as I couldnāt do it @tonykipā¦I understand that this could pose security issues. But there should be some way in which streamlit has to manage user credentials as well right?
This actually is not for testing purpose but asking for generic use cases where if user feels like they need to establish connection to their local db while using my cloud app, then experimental_connection canāt offer such thing right?
Maybe consider this project Business Card - ETL, where I am providing business card text extraction facility to user⦠This will work well if user clone and use it, provided, they have either global or local secrets file and provided the structure of the card is as expected by the program⦠Otherwise if they want to use my cloud app, then they canāt be able to input their own username and password when I use st.experimental_connectionā¦
Here in this project I refrained from using experimental_connection because of that reason and as you can see in the home page of this repo, I have another file which provides access to my own mongodb atlas db in order to support the cloud version of my app⦠This is what all I was talking aboutā¦
Simplifying things: There might be some scenario where user might want to import or export data from my cloud app to their local db. In those kinda situation, how can we establish connection to userās local db while using same st.experimental_connectionā¦
Hope this makes things clear⦠If not please feel free to ask more infoā¦
Thanks and Regards,
Nirmal
Hi @Nirmal_Kumar , how are you?
Did you find a way to solve your problem?
I am facing a very similar situationā¦
@tonykip, hope you are doing well,
I have a similar problem. Actually, is it possible to provide to us a tutorial of āHow to deploy project with streamlit and MySQLā ? I found only a documentation related to a local project on streamlit Documentation (Connect Streamlit to MySQL - Streamlit Docs).
Im my case, I have a sucessfull connection between MySQL remote dabatase and streamlit local project.
But when I try to deploy the project on streamlit web, I get some errors. I didnāt find a single person that did it sucessfully and posted on internet. We are really trying to discover how we can do a connection like that.
Thank You,
Lucas
1 Like
Hi @Nirmal_Kumar,
Thanks for posting!
Have you tried out the recent updates with st.experimental_connection
?
Try it out using this demo in the docs ā Connect Streamlit to MySQL - Streamlit Docs
I said about this !
@tonykip , could you help me, please?
Hi @Nirmal_Kumar,
Thanks for the clarification, for some reason I couldnāt see the previous thread when I responded.
So a deployed app cannot access your local instance of MySQL database directly. The main reason for this is that your local machine is most likely behind a router and a firewall that blocks incoming connections from the internet for security reasons. If you proceed with port forwarding to get incoming connections to port 8501, then you will end up exposing your local network to potential security threats; not advisable.
A more robust solution is to use a cloud database instance like AWS RDS which is already designed to be securely accessible.
Hello @tonykip !
My database is not local, is on a webserver. I can connect to this remote database when my streamlit project is local. But when I deploy the streamlit project, I receive some errors and I didnāt find on the documentation how can I do this. Even if the MySQL database is NOT LOCAL, streamlit isnāt capable of connect?
Updating from here⦠I found a way to do this connection, but I canāt do an authentication user with data from my MySQL remote database.