Microsoft Dev Blogs

Build a Streamlit application with Fabric SQL Database

thumbnail

Summary of Streamlit Application with Fabric SQL Database

Introduction

In this blog post, we will demonstrate how to build a Streamlit application that connects to a Fabric SQL database. The app will allow users to analyze inventory data, such as low stock items and sales trends, and make predictions for future inventory needs.

Setting Up Workspace and Database

  • Create a Workspace: Create a new workspace in Microsoft Fabric and choose Fabric capacity or Trial in the License mode section.
  • Create a SQL Database: Create a Fabric SQL database in the Workspace created earlier and populate it with sample data. Retrieve the ODBC connection string for the SQL Database.

Developing the Streamlit Application

  • Add Required Libraries: Install necessary libraries such as Streamlit, Pandas, and pyodbc.
  • App Development: Develop the Streamlit app by creating an app.py file with code to connect to the Fabric SQL database and display inventory data.

Testing Locally

  • Local Testing: Run the Streamlit app locally in Visual Studio code to view the data returned from the Fabric SQL database.
  • Visualization: The app will display a table with all products and a bar chart showing the count of products by model type.

Conclusion

The Streamlit application with Fabric SQL Database provides clear and concise visualizations of inventory data, enabling users to derive meaningful insights and make informed decisions.