Skip to content

Commit 6681662

Browse files
authored
Added Streamlit Quick Start guide (#74)
* completed streamlit quick start guide * fixed enumeration
1 parent ba0ddf7 commit 6681662

2 files changed

Lines changed: 67 additions & 0 deletions

File tree

sqlite-cloud/_nav.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const sidebarNav: SidebarNavStruct = [
1616
{ title: "Next.js", filePath: "quick-start-next", type: "inner", level: 1 },
1717
{ title: "Django", filePath: "quick-start-django", type: "inner", level: 1 },
1818
{ title: "Flask", filePath: "quick-start-flask", type: "inner", level: 1 },
19+
{ title: "Streamlit", filePath: "quick-start-streamlit", type: "inner", level: 1 },
1920
{ title: "PHP / Laravel", filePath: "quick-start-php-laravel", type: "inner", level: 1 },
2021

2122
{ title: "Platform", type: "secondary", icon: "docs-plat" },
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
title: Streamlit Quick Start Guide
3+
description: Get started with SQLite Cloud using Streamlit.
4+
category: getting-started
5+
status: publish
6+
slug: quick-start-streamlit
7+
---
8+
9+
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.
10+
11+
---
12+
13+
1. **Set up a SQLite Cloud account**
14+
- If you haven't already, [sign up for a SQLite Cloud account](https://sqlitecloud.io/register) and create a new database.
15+
- In this guide, we will use the sample datasets that come pre-loaded with SQLite Cloud.
16+
17+
2. **Create a Streamlit app**
18+
- You should have the latest Python version (3) installed locally.
19+
20+
```bash
21+
mkdir sqlc-quickstart
22+
cd sqlc-quickstart
23+
24+
python3 -m venv .venv
25+
. .venv/bin/activate
26+
27+
pip install streamlit
28+
```
29+
30+
3. **Install the SQLite Cloud SDK**
31+
32+
```bash
33+
pip install sqlitecloud
34+
```
35+
36+
4. **Query data**
37+
- Copy the following code into a new `app.py` file.
38+
- In your SQLite Cloud account dashboard, click your Project name, copy the Connection String, and replace `<your-connection-string>` below.
39+
40+
```py
41+
import streamlit as st
42+
import sqlitecloud
43+
import pandas as pd
44+
45+
st.header('Invoices')
46+
47+
conn = sqlitecloud.connect('<your-connection-string>')
48+
49+
db_name = "chinook.sqlite"
50+
conn.execute(f"USE DATABASE {db_name}")
51+
52+
invoices = pd.read_sql("SELECT * FROM invoices LIMIT 20", conn)
53+
54+
st.dataframe(invoices, hide_index=True)
55+
```
56+
57+
5. **Run your app**
58+
59+
```bash
60+
streamlit run app.py
61+
```
62+
63+
6. **View your app**
64+
- Open your browser and navigate to the localhost link provided by the previous command to see your app data.
65+
66+
And that's it! You've successfully built a Streamlit app that reads data from a SQLite Cloud database.

0 commit comments

Comments
 (0)