Database interaction
Do you have an example where solara is used to generate an interface allowing the user to interact with a database ?:
I am looking to build an app that allows
- reading info through a research bar (researching an email and displaying related info like associated group)
- editing info in the displayed results and saving it to the database
- writing a new line in a table thanks to a form-like component
I haven't seen the topic of database interaction mentioned in the docs.
3 Replies
Hi @Roman!
This is something that we've been meaning to write tutorials on for a while, but haven't gotten around to yet. You'd probably want to do all the fetching in a
solara.Task
/ use_task
, and then write it to a reactive state so that it can be edited. After any edits are done you can again write to the database in a task. One thing to look out for is the creation of database connections, for which solara.on_kernel_start
is probably useful. Without knowing what your database setup is like, I can't give you more advice on the specifics of it.Hi Roman
I am doing this with MariaDB, mainly using the Solara thread facility. Also I'm working with Apache Kafka which is a little more messy but still doable. So far I haven't seen any problems but my database operations are minimal and then doing joins and search/sorts in pandas.
Thanks fot the tips. I'll check those methods in the doc.
For testing purposes, i am simply using a .db file that is stored in my project locally (and is generated with a py script)
The goal is to be able to retrieve data from a (our) Datawarehouse (on Azure)
and access it via pyodbc