cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
cancel
Showing results for 
Search instead for 
Did you mean: 

Can anyone provide support on streamlit connectivity with databricks delta table/sql end point

ankris
New Contributor III

Can anyone provide support on streamlit connectivity with databricks delta table/sql end point

3 REPLIES 3

Anonymous
Not applicable

@ananthakrishna raikar​ :

Certainly! Streamlit can be used to connect to Databricks Delta tables and SQL endpoints through the use of the Databricks SQL Endpoint JDBC/ODBC driver.

Here's a sample code snippet to connect Streamlit with Databricks Delta:

import streamlit as st
import pandas as pd
import sqlalchemy
 
# Set up a connection to the Databricks SQL Endpoint using SQLAlchemy
# Replace with your own values for the JDBC/ODBC driver and endpoint URL
engine = sqlalchemy.create_engine("databricks+odbc://<Driver Name>:<Host Name>:<Port Number>?Authentication=<Auth Type>")
 
# Define a function to execute SQL queries and return the results as a Pandas dataframe
def run_query(query):
    with engine.connect() as con:
        rs = con.execute(query)
        df = pd.DataFrame(rs.fetchall(), columns=rs.keys())
    return df
 
# Example query to retrieve data from a Delta table
query = "SELECT * FROM my_delta_table"
 
# Call the function to execute the query and display the results in Streamlit
result_df = run_query(query)
st.dataframe(result_df)

Make sure to replace the values in the engine variable with your own JDBC/ODBC driver name, host name, port number, and authentication type.

Also, note that Databricks Delta tables can be accessed through the Databricks Delta JDBC driver, while Databricks SQL endpoints can be accessed through the Databricks SQL Endpoint JDBC/ODBC driver.

Anonymous
Not applicable

Hi @ananthakrishna raikar​ 

Thank you for posting your question in our community! We are happy to assist you.

To help us provide you with the most accurate information, could you please take a moment to review the responses and select the one that best answers your question?

This will also help other community members who may have similar questions in the future. Thank you for your participation and let us know if you need any further assistance! 

ankris
New Contributor III

Team,

Really i would like to thank you for prompt support.

Meantime am facing challenges while connecting delta table around 5 MB data.

we would like to connect minimum 150 MB data stored in delta table .

Appreciate your valuable guidance/support on the same.

Thanks in advance,

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.