-
Notifications
You must be signed in to change notification settings - Fork 2
/
minimal_example.py
23 lines (19 loc) · 943 Bytes
/
minimal_example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import streamlit as st
from streamlit_airtable import AirtableConnection
# Create connection
conn = st.connection("your_connection_name", type=AirtableConnection)
# Retrieve base schema
base_schema = conn.get_base_schema()
with st.expander("Base schema"):
st.json(base_schema)
# Get the first table's ID
first_table = base_schema["tables"][0]
st.markdown(f"First table ID: `{first_table['id']}` (named `{first_table['name']}`)")
# Retrieve all records for the first table (pyAirtable paginates automatically)
# (Note you can also pass in parameters supported by pyAirtable
# (https://pyairtable.readthedocs.io/en/stable/api.html#parameters) such as as
# max_records, view, sort, and formula into conn.query() like so:
# table_records = conn.query(first_table["id"], max_records=25, view='viwXXX')
table_records = conn.query(table_id=first_table["id"])
st.markdown(f"{len(table_records)} records retrieved")
st.dataframe(table_records)