I am connecting dremio with Jupyter notebook and getting following error while connecting with pyodbc.
**Error : ** Error connecting to Dremio: (‘08S01’, ‘[08S01] [Apache Arrow][Flight SQL] (500) Flight returned unavailable error, with message: failed to connect to all addresses. Please ensure your encryption settings match the server. (500) (SQLDriverConnect)’)
I have explored the following link but still could not fix my isye
try:
connection = pyodbc.connect(connection_string, autocommit=True)
print(“Connected to Dremio successfully.”)
# Execute a query
cursor = connection.cursor()
cursor.execute('SELECT * FROM "Data Platfrom Archive".ci1."ur_sms_traffic"') # Adjust the query as needed
for row in cursor:
print(row)
cursor.close()
except Exception as e:
print(f"Error connecting to Dremio: {e}")
finally:
if ‘connection’ in locals() and connection:
connection.close()
print(“Connection closed.”)
I have edited your post to remove your admin password. Please change your Admin password immediately as it has been exposed! Also please consider locking down access to your Dremio environment via a firewall as well.
For you question, there are two methods for a python environment:
via pyodbc:
# Install the driver
# !wget https://download.dremio.com/arrow-flight-sql-odbc-driver/arrow-flight-sql-odbc-driver-LATEST.x86_64.rpm
# !sudo yum localinstall -y arrow-flight-sql-odbc-driver-LATEST.x86_64.rpm
# Find other drivers for other OS's here: https://download.dremio.com/arrow-flight-sql-odbc-driver/
import pyodbc
import pandas
host = 'your_host'
port = 32010
uid = 'your_user'
pwd = 'your_pass'
#If you're using a MacOS, the driver is located here -> /Library/Dremio/ODBC/lib/libarrow-flight-sql-odbc.dylib; the below is for linux:
driver = "/opt/arrow-flight-sql-odbc-driver/lib64/libarrow-odbc.so.0.9.1.168"
#Set UseEncryption accordingly below:
cnxn=pyodbc.connect("Driver={};ConnectionType=Direct;HOST={};PORT={};AuthenticationType=Plain;UID={};PWD={}".format(driver,host,port,uid,pwd),autocommit=True,UseEncryption=False)
#Your query
sql = 'select * from sys.options limit 3'
data = pandas.read_sql(sql, cnxn)
print(data)