Here at Purple Frog Systems, I’ve been experimenting with pure Python Notebooks rather than PySpark Notebooks for small to medium datasets, due to their super quick start up time and reduced CU consumption for customers with smaller F-SKUs.

https://learn.microsoft.com/en-us/fabric/data-engineering/fabric-notebook-selection-guide

When scrolling through LinkedIn I came across a Microsoft Blog which allows you to combine T-SQL and Python within the same notebook, using a T-SQL magic command.

https://learn.microsoft.com/en-us/fabric/data-engineering/tsql-magic-command-notebook

This is really handy if you’re a data engineer who wants to use T-SQL but still have the flexibility of Python notebooks to transform data and write it back to the Lakehouse with DuckDB.

My syntax below, remember this is a pure Python session.

To check out the full syntax, just type %tsql? in a cell. It’ll bring up the help info for the T-SQL magic command, including all the available parameters and what they do.

Hope this helps those people moving from T-SQL to Python.

Tags: ,