Replies: 1 comment
-
Flet is frontend, a database is a backend. Use a function or a class to retrieve your data. I would suggest that you use SQLAlchemy or Pandas to get your data from Postgres. For instance, below is code to fetch data from vega_datasets. You should get your data from your db here. I'm using pandas here ... You can see how I go from a dataframe which is pandas, to a tuple of lists for example.
Here you have a sample on how I get the data above into a plotly graph
There are some of my functions to make the graph:
You would include the above in a page with:
The following code uses pandas to read postgres:
My function to create a datatable from the column names and rows is this:
Works in both desktop as web version. I can't show you that because I'm only using it in a web version with FastAPI, which I run via uvicorn that I'm running in. |
Beta Was this translation helpful? Give feedback.
-
Question
Hello, I have a database in postgres and I would like to connect.
1.- Does anyone know how to connect postgres with Flet?
2.- I want to make graphical reports (Dashboard) can it be done in desktop mode or is it necessary to switch to web mode with flet?
Hola, tengo una base de datos en postgres y me gustaría conectarme.
1.- ¿Alguien sabe cómo conectar postgres con Flet?
2.- Quiero hacer informes gráficos (Dashboard) ¿se puede hacer en modo escritorio o es necesario cambiar al modo web con flet?
Code sample
No response
Error message
No response
------------------------------------------------------
Beta Was this translation helpful? Give feedback.
All reactions