cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
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,

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group