Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

Is your feature request related to a problem? Please describe.

After reading this thread: https://www.reddit.com/r/MicrosoftFabric/comments/1p5oduh/mssqlpython_with_pandas_or_polars_warnings_and/, I think we have an opportunity to improve the experience.

The current experience using mssql-python with Fabric Notebooks has a ton of friction. Here's an example:

`import struct
import mssql_python
import pandas as pd

connection_string = (
f"Server={server};"
f"Database={database};"
"Encrypt=yes;"
)

access_token = notebookutils.credentials.getToken('pbi')
token = access_token.encode("UTF-16-LE")
token_struct = struct.pack(f'<I{len(token)}s', len(token), token)
SQL_COPT_SS_ACCESS_TOKEN = 1256

connection = mssql_python.connect(connection_string, attrs_before={SQL_COPT_SS_ACCESS_TOKEN: token_struct})

tables = ["Customers", "Invoices", "Orders"]

for table in tables:
query = f"SELECT TOP 5 * FROM Sales.{table}"
pd_data = pd.read_sql_query(query, connection)

print(pd_data.dtypes)
print(pd_data.info())
print(pd_data)
display(pd_data)

Close the connection

connection.close()`

Describe the solution you'd like

We could improve on this quite a bit by adding a Fabric Notebook connection option and allowing worskpace and database name to be passed like it is with tsql magic in Fabric Notebooks. Here's an example:

`import struct
import mssql_python
import pandas as pd

connection_string = (
f"Workspace={workspace};"
f"Database={database};"
"Authentication=FabricNotebook;"
"Encrypt=yes;"
)

connection = mssql_python.connect(connection_string)

tables = ["Customers", "Invoices", "Orders"]

for table in tables:
query = f"SELECT TOP 5 * FROM Sales.{table}"
pd_data = pd.read_sql_query(query, connection)

print(pd_data.dtypes)
print(pd_data.info())
print(pd_data)
display(pd_data)

Close the connection

connection.close()`

Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered.

Additional context

This seems to be a fairly standard pattern: https://www.reddit.com/r/MicrosoftFabric/comments/1p6mkn3/connect_to_fabric_warehouse_from_python_notebook/

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
💡
Ideas
Labels
enhancement New feature or request question Further information is requested triage done Issues that are triaged by dev team and are in investigation. pr-size: medium Moderate update size
1 participant
Converted from issue

This discussion was converted from issue #349 on December 03, 2025 22:34.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.