I query cassandra database, and I’m able to get data with 33 millions rows fastly,
https://docs.datastax.com/en/developer/python-driver/3.23/getting_started/
streamlit 
I query cassandra database, and I’m able to get data with 33 millions rows fastly,
https://docs.datastax.com/en/developer/python-driver/3.23/getting_started/
streamlit 
Thanks for sharing @NotAfk! Don’t think we’ve had anyone let us know about a Streamlit app using Cassandra.
Is this something you can share, or is this private/work-related?
# import library
import cassandra
from cassandra.cluster import Cluster
from cassandra.auth import PlainTextAuthProvider
# Connection to cassandra database
auth_provider = PlainTextAuthProvider(
username='username', password='password')
cluster = Cluster(['srv-spotfire'], auth_provider=auth_provider)
session = cluster.connect()
# Query Cassandra
if (launch) and (end_date > start_date):
tic = time()
rowsTag = session.execute("SELECT name, timestamp, value FROM cluster.table WHERE name in "+str(tuple(tag_select))+" and year in "+str(tuple(year_range))+" and timestamp >= $$"+str(start_date)+"$$ and timestamp <= $$"+str(end_date)+"$$;")
toc = time()
total = toc - tic
taglist = []
for row in rowsTag :
lister = [row.name, row.timestamp, row.value]
taglist.append(lister)
if len(taglist) != 0:
tag_df = pd.DataFrame(taglist)
After that, data will be exported into csv file,
and I use Spotfire to open large .csv file.
But I have a bug to report => I don’t know if this is related to the power of the machine / web navigator. When I use st.markdown() to make a download link for large data file, a blank page appear.(no shutdown of streamlit). I use this function to generate an download link.
def get_table_download_link(df):
“”“Generates a link allowing the data in a given panda dataframe to be downloaded
in: dataframe
out: href string
“””
csv = df.to_csv(index = False, sep =“;”, encoding = “latin-1”, chunksize = 15000000)
b64 = base64.b64encode(csv.encode()).decode() # some strings ↔ bytes conversions necessary herereturn f'<a href="data:file/csv;base64,{b64}" download="data.csv">Download csv file</a>'
How large is “large” in your case?
I will give you an answer with more detail when I get back to office
streamlit==0.58.0
CentOS Linux release 7.7.1908 (Core)
Web navigator = Google chrome Version 83.0.4103.106 (Build officiel) (64 bits)
: Blank page appear
: Nothing to report
Edit 1 : same behaviour in Microsoft Edge
The thing about creating a download link by passing the bytes is that it actually puts those bytes into the webpage. This is fine for a small amount of data, but at larger amounts, it probably does something weird to the browser (i.e. no one is expecting a 10GB webpage).
A proper file download solution is on our roadmap, but as of right now, I don’t know the timing of that feature.