I want to connect my streamlit app with public google sheets.
Therefore i had followed some pre-requisites Connect Streamlit to a public Google Sheet.
Following are some pre-requisite i have adhered:
-
Creation of .streamlit/secrets.toml file & pasted sheet url link inside it.
-
Added gsheetsdb==x.x.x version to requirements.txt file.
Following is public google sheet.
Following is code:
import streamlit as st
from gsheetsdb import connect
# Create a connection object.
conn = connect()
# Perform SQL query on the Google Sheet.
# Uses st.cache to only rerun when the query changes or after 10 min.
@st.cache(ttl=600)
def run_query(query):
rows = conn.execute(query, headers=1)
rows = rows.fetchall()
return rows
sheet_url = st.secrets["public_gsheets_url"]
rows = run_query(f'SELECT * FROM "{sheet_url}"')
# Print results.
for row in rows:
st.write(f" User: {row.Email} has password :{row.Password}:")
I am getting following errors:
ImportError: cannot import name 'Iterable' from 'collections' (C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\collections\__init__.py)
Traceback:
File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 564, in _run_script
exec(code, module.__dict__)
File "C:\Users\User\Desktop\Development\Minor Project\Sentiment Analysis Web APP\dbfetch.py", line 2, in <module>
from gsheetsdb import connect
File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\gsheetsdb\__init__.py", line 1, in <module>
from gsheetsdb.db import connect
File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\gsheetsdb\db.py", line 11, in <module>
from gsheetsdb.query import execute
File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\gsheetsdb\query.py", line 11, in <module>
from moz_sql_parser import parse as parse_sql
File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\moz_sql_parser\__init__.py", line 15, in <module>
from moz_sql_parser.sql_parser import SQLParser, scrub_literal, scrub
File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\moz_sql_parser\sql_parser.py", line 12, in <module>
from mo_parsing.engine import Engine
File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\mo_parsing\__init__.py", line 60, in <module>
from mo_parsing.infix import LEFT_ASSOC, RIGHT_ASSOC, infixNotation
File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\mo_parsing\infix.py", line 4, in <module>
from collections import Iterable
I am doing my graduation minor project using streamlit please help me out. Your help will really be appreciable.