Streamlit Quick Start Guide
In this quickstart, we will show you how to get started with SQLite Cloud and Streamlit by building a simple application that connects to and reads from a SQLite Cloud database.
- Set up a SQLite Cloud account
- If you haven’t already, sign up for a SQLite Cloud account and create a new project.
- In this guide, we will use the sample datasets that come pre-loaded with SQLite Cloud.
- Create a Streamlit app
- You should have the latest Python version (3) installed locally.
mkdir sqlc-quickstart
cd sqlc-quickstart
python3 -m venv .venv
. .venv/bin/activate
pip install streamlit
- Install the SQLite Cloud SDK
pip install sqlitecloud
- Query data
- Copy the following code into a new
app.py
file. - In your SQLite Cloud account dashboard, click your Project name, copy the Connection String, and replace
<your-connection-string>
below.
import streamlit as st
import sqlitecloud
import pandas as pd
st.header('Invoices')
conn = sqlitecloud.connect('<your-connection-string>')
db_name = "chinook.sqlite"
conn.execute(f"USE DATABASE {db_name}")
invoices = pd.read_sql("SELECT * FROM invoices LIMIT 20", conn)
st.dataframe(invoices, hide_index=True)
- Run your app
streamlit run app.py
- View your app
- Open your browser and navigate to the localhost link provided by the previous command to see your app data.
And that’s it! You’ve successfully built a Streamlit app that reads data from a SQLite Cloud database.