Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Special holiday offer! You and a friend can attend FabCon with a BOGO code. Supplies are limited. Register now.

Reply
spartan27244
Resolver I
Resolver I

SQL Database (preview)

when using the data warehouse feature of Fabric in PySpark I can connect to the data warehouse and run a query as so...

df = spark.read.option(Constants.DatabaseName, DataWarehouse).synapsesql(SQL)
with the addition of the SQL database in Fabric how do I query that in PySpark?
 
NOTE: I am new at this.
1 ACCEPTED SOLUTION
Ranganath_M
Advocate I
Advocate I

Data querying within the SQL database (preview) from a notebook is feasible only when the default language of the notebook is set to T-SQL. Upon switching the language to PySpark or Python, querying capabilities are limited to the Lakehouse, and not the databases.

 

So currently, to execute any PySpark notebooks on the SQL database data, it is necessary to first ingest the data from the database into the Lakehouse using pipelines. Subsequently, PySpark notebooks can be run on the ingested data

View solution in original post

4 REPLIES 4
Ranganath_M
Advocate I
Advocate I

Data querying within the SQL database (preview) from a notebook is feasible only when the default language of the notebook is set to T-SQL. Upon switching the language to PySpark or Python, querying capabilities are limited to the Lakehouse, and not the databases.

 

So currently, to execute any PySpark notebooks on the SQL database data, it is necessary to first ingest the data from the database into the Lakehouse using pipelines. Subsequently, PySpark notebooks can be run on the ingested data

That does appear to be the case although the documentaion and videos do not address this at all. Hopefully Microsoft will relize the importance of this.

nilendraFabric
Super User
Super User

Hi @spartan27244 

 

If I am not wrong When you use SQL Database (preview) in Microsoft Fabric, the platform automatically replicates your data into OneLake and converts it to Parquet/Delta tables in an analytics-ready format.

 

Try this

 

df = spark.sql("""
SELECT *
FROM [YourSQLDatabaseName].[dbo].[YourTable]
""")

 Or 

 


df = spark.read.table("[YourSQLDatabaseName].[dbo].[YourTable]")

display(df)

I believe you are referring to the scenario where I have an Azure SQL database and select from that Azure database to Replicate in Fabric. 

 

I am referring to is within fabric you can now create a SQL database, which I did. Those tables are not reflected as delta tabless so I am trying to figure out how to read this data in PySpark.

Helpful resources

Announcements
December Fabric Update Carousel

Fabric Monthly Update - December 2025

Check out the December 2025 Fabric Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors