
- #RUN A PYTHON FILE IN ANACONDA PROMPT FOR FREE#
- #RUN A PYTHON FILE IN ANACONDA PROMPT HOW TO#
- #RUN A PYTHON FILE IN ANACONDA PROMPT INSTALL#
- #RUN A PYTHON FILE IN ANACONDA PROMPT DRIVERS#
This demonstration is going to use the Adventure Works sample database provided by Microsoft on CodePlex. This blog post has been developed using SQL Server 2016 with pyodbc version 3.0.1. NOTE: The recently released SQL Server 2017 and SQL Server on Azure both require pyodbc version >= 3.2.
#RUN A PYTHON FILE IN ANACONDA PROMPT FOR FREE#
If you do not have Microsoft SQL Server it can be downloaded and installed for free and is now available for Windows and Linux.
#RUN A PYTHON FILE IN ANACONDA PROMPT HOW TO#
The following provides details on how to setup your SQL Server instance to be able to exactly replicate the client-side Python-based connection that follows.

The Windows and Mac Python examples were using Anaconda 4.3 with Python 3.6 and pyodbc version 3.0, while the Linux example used Anaconda Enterprise, based on Anaconda 4.2, using Python 2.7. My Mac was running macOS 10.12.4, and my client-side Windows system also used Windows 10. In all cases I was running SQL Server 2016 on a Windows 10 system. While this isn't meant to be an exhaustive reference for SQL Server connectivity from Python and Anaconda it does cover several client/server configurations. As well as a fully worked out example of client-side connection and query.Īnd you can grab a copy of this blog post as a Jupyter Notebook from Anaconda Cloud.
#RUN A PYTHON FILE IN ANACONDA PROMPT DRIVERS#
Here's the scoop: the Python piece is easy (yay Python!) whereas the challenges are installing the platform-specific drivers (Step 1), and if you don't already have a database properly setup then the SQL Server installation, configuration, database loading, and setting up appropriate security credentials are the parts that the rest of this blog post are going to go into in more detail. Hopefully that doesn't look too intimidating! R'DRIVER= SERVER=,1433 DATABASE=AdventureWorksDW2012 UID=tanya PWD=Tanya1234' That is described in the Client Driver Installation section below.Įstablish a connection to the SQL Server database with an appropriately constructed connection statement: conn = nnect(
#RUN A PYTHON FILE IN ANACONDA PROMPT INSTALL#
Install the SQL Server drivers for your platform on the client system. If you're the kind of person who just wants the punch line and not the story, there are three core steps to connect to an existing SQL Server database: If you run into any trouble let us know either through the Anaconda Community Support mailing list or on Twitter TL DR: For the Impatient The instructions should work for many versions SQL Server, Python and Anaconda, including Anaconda Enterprise, our commercially oriented version of Anaconda that adds in strong collaboration, security, and server deployment capabilities.


This blog post demonstrates how Anaconda and Anaconda Enterprise can be used on the client-side to connect Python running on Windows, Mac, or Linux to a SQL Server instance. With the news that Microsoft SQL Server 2017 has increased support for Python, by including a subset of Anaconda packages on the server-side, I thought it would be useful to demonstrate how Anaconda delivers the easy button to get Python on the client side connected to Microsoft SQL Server.

Previously there were many twisty roads that you may have followed if you wanted to use Python on a client system to connect to a Microsoft SQL Server database, and not all of those roads would even get you to your destination.
