So Microsoft have integrated Python into SQL Server, from the moment I heard that I thought to myself, “wow, this is exciting stuff” and not just for the machine learning, BI guys that it was marketed at. It’s exciting for us DBAs too, my head was in a buzz with all the things that we could do with it.

That was all well and good but I got even more excited when I realised that we’d not been given some watered down baby python but a full on 12′ long Burmese monster that can also import external modules.

Think about that, all those powerful Python modules that are out there can be imported and used by SQL Server. Crazy stuff!

But how do we go about installing them into SQL Server? Now I’m a DBA and not a Python wizz so had to do a little digging to figure it out but to be honest, it’s fairly easy.

I don’t know how many other DBAs know that we can install these modules or even how to do it so I thought I’d write up a quick post explaining it.

First things first, you’re going to need to do this from your SQL Server.

Open up a command prompt and navigate to the Python scripts folder, you’ll find that inside the PYTHON_SERVICES directory in your SQL installation location (ie C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\PYTHON_SERVICES)

(or in the case of my Python test instance…)

Once there, you can easily install your modules using ‘pip’. I had no idea what that was either but it turns out that it’s a funky little bit of kit that goes out to the Python Package Index (some mystical cloud location where all the Python goodness lives, known as PyPi by the cool, dev types), downloads and installs modules for you.

how I imagine PyPi looks

pip install ModuleName

hit enter and your module will download and install, ready for you to have all sorts of fun with.

For a full list and details of the Python modules that are available to you, check out https://pypi.org

That’s just a quickie but hopefully it’ll start you thinking about all the possibilities that Python gives us.

In my next post I’ll give you a fun example of something really cool that I’ve managed to do with Python and an external module.

David Fowler

David is a DBA with over 14 years production experience of SQL Server, from version 6.5 through to 2016. He has worked in a number of different settings and is currently the technical lead at one of the largest software companies in the UK.

Adrian Buckman

After working in the motor trade for over 11 years Adrian decided to give it all up to persue a dream of working in I.T. Adrian has over 4 years of experience working with SQL server and loves all things SQL, Adrian currently works as a Database Administrator for one of the UK’s Largest Software Companies