<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: not able to run python script even after everything is in place in azure data bricks in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/not-able-to-run-python-script-even-after-everything-is-in-place/m-p/115056#M45019</link>
    <description>&lt;P&gt;The community here is going to need a bit more than what you posted.&amp;nbsp; Need full context before we can attempt to address your question. Thanks, Lou.&lt;/P&gt;</description>
    <pubDate>Wed, 09 Apr 2025 18:22:12 GMT</pubDate>
    <dc:creator>Louis_Frolio</dc:creator>
    <dc:date>2025-04-09T18:22:12Z</dc:date>
    <item>
      <title>not able to run python script even after everything is in place in azure data bricks</title>
      <link>https://community.databricks.com/t5/data-engineering/not-able-to-run-python-script-even-after-everything-is-in-place/m-p/114979#M45004</link>
      <description>&lt;P&gt;getting the below error while running a python which connects to azure sql db&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Database connection error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 17 for SQL Server' : file not found (0) (SQLDriverConnect)")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;can some one help me out&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Apr 2025 13:49:03 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/not-able-to-run-python-script-even-after-everything-is-in-place/m-p/114979#M45004</guid>
      <dc:creator>lsrinivas2k13</dc:creator>
      <dc:date>2025-04-09T13:49:03Z</dc:date>
    </item>
    <item>
      <title>Re: not able to run python script even after everything is in place in azure data bricks</title>
      <link>https://community.databricks.com/t5/data-engineering/not-able-to-run-python-script-even-after-everything-is-in-place/m-p/115056#M45019</link>
      <description>&lt;P&gt;The community here is going to need a bit more than what you posted.&amp;nbsp; Need full context before we can attempt to address your question. Thanks, Lou.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Apr 2025 18:22:12 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/not-able-to-run-python-script-even-after-everything-is-in-place/m-p/115056#M45019</guid>
      <dc:creator>Louis_Frolio</dc:creator>
      <dc:date>2025-04-09T18:22:12Z</dc:date>
    </item>
    <item>
      <title>Re: not able to run python script even after everything is in place in azure data bricks</title>
      <link>https://community.databricks.com/t5/data-engineering/not-able-to-run-python-script-even-after-everything-is-in-place/m-p/115107#M45027</link>
      <description>&lt;P&gt;I am trying to run a python script in azure data bricks environment where the script will fetch the certificate details of URLS and dump them into Azure SQL database.&lt;/P&gt;&lt;P&gt;while running the script either through a notebook or through a job i am getting the following error .&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Database connection error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 17 for SQL Server' : file not found (0) (SQLDriverConnect)")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I am attaching the code for your reference.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Apr 2025 07:25:50 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/not-able-to-run-python-script-even-after-everything-is-in-place/m-p/115107#M45027</guid>
      <dc:creator>lsrinivas2k13</dc:creator>
      <dc:date>2025-04-10T07:25:50Z</dc:date>
    </item>
    <item>
      <title>Re: not able to run python script even after everything is in place in azure data bricks</title>
      <link>https://community.databricks.com/t5/data-engineering/not-able-to-run-python-script-even-after-everything-is-in-place/m-p/115165#M45035</link>
      <description>&lt;P&gt;The error occurs because the Microsoft ODBC Driver 17 for SQL Server is missing on your Azure Databricks cluster. Here's how to fix it:&lt;/P&gt;
&lt;P&gt;Steps to Resolve&lt;/P&gt;
&lt;P&gt;Step 1: Create an Init Script to Install ODBC Driver&lt;BR /&gt;1. Create a file named `odbc-install.sh` with the following content:&lt;BR /&gt;```bash&lt;BR /&gt;#!/bin/bash&lt;BR /&gt;curl &lt;A href="https://packages.microsoft.com/keys/microsoft.asc" target="_blank"&gt;https://packages.microsoft.com/keys/microsoft.asc&lt;/A&gt; | apt-key add -&lt;BR /&gt;curl &lt;A href="https://packages.microsoft.com/config/ubuntu/22.04/prod.list" target="_blank"&gt;https://packages.microsoft.com/config/ubuntu/22.04/prod.list&lt;/A&gt; &amp;gt; /etc/apt/sources.list.d/mssql-release.list&lt;BR /&gt;apt-get update&lt;BR /&gt;ACCEPT_EULA=Y apt-get -y install msodbcsql17&lt;BR /&gt;apt-get -y install unixodbc-dev&lt;BR /&gt;```&lt;/P&gt;
&lt;P&gt;2. Save this script in your Databricks workspace.&lt;/P&gt;
&lt;P&gt;Step 2: Attach Init Script to Your Cluster&lt;BR /&gt;1. Go to your cluster configuration in Databricks.&lt;BR /&gt;2. Under "Advanced" settings, find the "Init Scripts" section.&lt;BR /&gt;3. Add the script by selecting "Workspace" as the source and providing the path (e.g., `/Workspace/odbc-install.sh`).&lt;BR /&gt;4. Restart your cluster.&lt;/P&gt;
&lt;P&gt;---&lt;/P&gt;
&lt;P&gt;### Step 3: Update Connection String in Your Code&lt;BR /&gt;Modify the connection string in your `connect_to_database` function to explicitly use the installed driver:&lt;/P&gt;
&lt;P&gt;```python&lt;BR /&gt;conn = pyodbc.connect(&lt;BR /&gt;f'DRIVER={{ODBC Driver 17 for SQL Server}};SERVER={server};DATABASE={database};UID={username};PWD={password}'&lt;BR /&gt;)&lt;BR /&gt;```&lt;/P&gt;
&lt;P&gt;---&lt;/P&gt;
&lt;P&gt;Step 4: Test the Setup&lt;BR /&gt;Run this snippet in a Databricks notebook to confirm the driver is installed:&lt;BR /&gt;```python&lt;BR /&gt;import pyodbc&lt;/P&gt;
&lt;P&gt;# List available drivers&lt;BR /&gt;print(pyodbc.drivers())&lt;BR /&gt;```&lt;BR /&gt;Ensure `ODBC Driver 17 for SQL Server` appears in the output.&lt;/P&gt;
&lt;P&gt;---&lt;/P&gt;
&lt;P&gt;Alternative Approach&lt;BR /&gt;If issues persist, consider using JDBC instead of ODBC for database connections:&lt;BR /&gt;```python&lt;BR /&gt;from pyspark.sql import SparkSession&lt;/P&gt;
&lt;P&gt;spark = SparkSession.builder.appName("Certificate Data").getOrCreate()&lt;/P&gt;
&lt;P&gt;df = spark.read.format("jdbc").option("url", f"jdbc:sqlserver://{server}:1433;databaseName={database}") \&lt;BR /&gt;.option("dbtable", "SSLCertificateData") \&lt;BR /&gt;.option("user", username) \&lt;BR /&gt;.option("password", password).load()&lt;BR /&gt;```&lt;/P&gt;
&lt;P&gt;Summary&lt;BR /&gt;- Install ODBC Driver 17 using an init script.&lt;BR /&gt;- Update your connection string to use `ODBC Driver 17 for SQL Server`.&lt;BR /&gt;- Test installation with `pyodbc.drivers()` or switch to JDBC for simpler integration.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Apr 2025 14:24:03 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/not-able-to-run-python-script-even-after-everything-is-in-place/m-p/115165#M45035</guid>
      <dc:creator>Louis_Frolio</dc:creator>
      <dc:date>2025-04-10T14:24:03Z</dc:date>
    </item>
  </channel>
</rss>

