<?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: SQL Connection string shared accross all Onelakes in Data Warehouse</title>
    <link>https://community.fabric.microsoft.com/t5/Data-Warehouse/SQL-Connection-string-shared-accross-all-Onelakes/m-p/4323298#M2222</link>
    <description>&lt;P&gt;Thanks for your answer and the explanation about &lt;SPAN&gt;SQL analytics endpoints !&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;I tried requesting my selected lakehouse within the query to make it more flexible like this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;cursor.execute("SELECT * FROM Lakehouse_name.dbo.my_table")&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;Works like a charm,&lt;BR /&gt;&lt;BR /&gt;Thanks again !&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 11 Dec 2024 08:12:04 GMT</pubDate>
    <dc:creator>jbshml</dc:creator>
    <dc:date>2024-12-11T08:12:04Z</dc:date>
    <item>
      <title>SQL Connection string shared accross all Onelakes</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Warehouse/SQL-Connection-string-shared-accross-all-Onelakes/m-p/4322115#M2218</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;I'm currently facing an issue while trying to query my SQL analytics endpoints from my local machine using Python script.&lt;BR /&gt;In my selected workspace, I have 3 onelakes (named Bronze, Silver and Gold: created historically in this given order)&lt;BR /&gt;&lt;BR /&gt;However,&amp;nbsp; all of them share the same SQL Connection string provided, making it impossible to reach all of them, and they all seems to be related to the Bronze's one. I even tried to remove the database inside the&amp;nbsp;&lt;SPAN&gt;connection_string below, but I still can't get my Silver and Gold list of tables or whatever -&amp;nbsp;&lt;/SPAN&gt;Is it an expected behavior or something that I'm missing ?&lt;BR /&gt;&lt;BR /&gt;Below the python code&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import pyodbc
from azure.identity import InteractiveBrowserCredential, AzureCliCredential
import struct
from itertools import chain, repeat
import pandas as pd

sql_endpoint = "thecommonendpoint.datawarehouse.fabric.microsoft.com"

credential = AzureCliCredential() # replace by InteractiveBrowserCredential() if needed

token = credential.get_token("https://database.windows.net/.default")
token_as_bytes = bytes(token.token, "UTF-8")
encoded_bytes = bytes(chain.from_iterable(zip(token_as_bytes, repeat(0))))
token_bytes = struct.pack("&amp;lt;i", len(encoded_bytes)) + encoded_bytes

connection_string = (
    f"Driver={{ODBC Driver 18 for SQL Server}};Server={sql_endpoint},1433;Encrypt=Yes;TrustServerCertificate=No"
)

conn = pyodbc.connect(connection_string, attrs_before={1256: token_bytes})

query = "SELECT * FROM sys.tables;" #List tables

df = pd.read_sql(query, conn)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thanks in advance for your enlightment&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Dec 2024 16:05:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Warehouse/SQL-Connection-string-shared-accross-all-Onelakes/m-p/4322115#M2218</guid>
      <dc:creator>jbshml</dc:creator>
      <dc:date>2024-12-10T16:05:55Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Connection string shared accross all Onelakes</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Warehouse/SQL-Connection-string-shared-accross-all-Onelakes/m-p/4322771#M2221</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="761798" data-lia-user-login="jbshml" class="lia-mention lia-mention-user"&gt;jbshml&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can think of SQL Connection string as a server name, and each workspace is equivalent to a server. Therefore, all SQL analytics endpoints, data warehouses, SQL databases and mirrored databases in the same workspace share the same SQL Connection string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I connect to a SQL Connection string in SSMS, and it shows all of above Fabric items as databases on the server. Just like below.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;UPDATE:&lt;/P&gt;
&lt;P&gt;Based on your python code, I used the following code, which was able to read data from the database specified in the connection string. I don't use Pandas here.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;import pyodbc
from azure.identity import InteractiveBrowserCredential, AzureCliCredential
import struct
from itertools import chain, repeat
import pandas as pd

sql_endpoint = "xxxxxxxxxxxxx.datawarehouse.fabric.microsoft.com"
database_name = "your_lakehouse_name"

# credential = AzureCliCredential() # replace by InteractiveBrowserCredential() if needed
credential = InteractiveBrowserCredential()

token = credential.get_token("https://database.windows.net/.default")
token_as_bytes = bytes(token.token, "UTF-8")
encoded_bytes = bytes(chain.from_iterable(zip(token_as_bytes, repeat(0))))
token_bytes = struct.pack("&amp;lt;i", len(encoded_bytes)) + encoded_bytes

connection_string = (
    f"Driver={{ODBC Driver 18 for SQL Server}};Server={sql_endpoint},1433;Database={database_name};Encrypt=Yes;TrustServerCertificate=No"
)

conn = pyodbc.connect(connection_string, attrs_before={1256: token_bytes})

cursor = conn.cursor()

cursor.execute("select * from sys.tables")

for row in cursor:
    print(row)

conn.close()&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using Pandas version:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;connection_string = (
    f"Driver={{ODBC Driver 18 for SQL Server}};Server={sql_endpoint},1433;Database={database_name};Encrypt=Yes;TrustServerCertificate=No"
)

conn = pyodbc.connect(connection_string, attrs_before={1256: token_bytes})

query = "SELECT * FROM sys.tables"

df = pd.read_sql(query, conn)

conn.close()

print(df.head())&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Jing&lt;BR /&gt;If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!&lt;/P&gt;</description>
      <pubDate>Wed, 11 Dec 2024 06:23:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Warehouse/SQL-Connection-string-shared-accross-all-Onelakes/m-p/4322771#M2221</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-12-11T06:23:51Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Connection string shared accross all Onelakes</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Warehouse/SQL-Connection-string-shared-accross-all-Onelakes/m-p/4323298#M2222</link>
      <description>&lt;P&gt;Thanks for your answer and the explanation about &lt;SPAN&gt;SQL analytics endpoints !&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;I tried requesting my selected lakehouse within the query to make it more flexible like this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;cursor.execute("SELECT * FROM Lakehouse_name.dbo.my_table")&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;Works like a charm,&lt;BR /&gt;&lt;BR /&gt;Thanks again !&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Dec 2024 08:12:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Warehouse/SQL-Connection-string-shared-accross-all-Onelakes/m-p/4323298#M2222</guid>
      <dc:creator>jbshml</dc:creator>
      <dc:date>2024-12-11T08:12:04Z</dc:date>
    </item>
  </channel>
</rss>

