Save and Share information between users

Hi Dash Community, Happy New Year for all of you :star_struck:

I’m starting the 2022 with a project to build an app to be deployed in Heroku that allows different users to have and manage different Stock Portfolios, but I have a limited knowledge about how to save and maintain persistent information to allow the users to use them in future sessions.

For example, the idea is to have a database where each new user can register and log in to the app and this simple register record (let say user name, email and password) be saved in the db for future logins. Also I need to save in a DB the different Portfolios defined by each user.

As I understand, the information saved in the app will be there during the user´s session but wont be persistent for futures sessions.

Is this correct?

How can I solve this issue?

Thanks in advance for your help. :grinning:

You need somewhere to store the data. If you all you want is to persist small amounts of data between sessions, you can use the Storage component with storage_type='local'. However, with this approach you are still saving the data in the browser. Hence the data will not be persisted across devices, and if the browser storage is cleared, the data is lost. Hence, I would say that for your use case, a separate database seems like a better fit.

2 Likes

Hi @Emil , thanks for your answer. :smiley:

Yes, thats what I need, but how can I implement a separate database ? :thinking:

Do you have any link where I can read about this kind of solution?

Thanks,
Eduardo.

Database I a huge topic of it’s own. Larger than Dash itself, I would say. If you are just playing around locally, you could try out sqlite. For self-hosted production use, I have used PostgreSQL a lot in the past, but the “best” choice really depends on the use case. From what I understand about your use case so far, it doesn’t seem that you have very specific requirements, so I would start by looking into what types of database are available from your current infrastructure provider. That might ease the development process.

I’m familiar with sqlite3 and in this specific project I’m using a login implementation that uses sqlalchemy, the problem is that when I use it in Heroku it store the information but only for the current session. Then in a different session (or with a different user) it goes back to the original database uploded.

Is there any way to use them in a way that the information persist for future sessions?

Thank again for your help.