Using PowerShell with Python & SQL Server June 10, 2017 Maximo Trinidad
1 2 3 4 5 Understanding Your Environment PowerShell and SQL Server Python SQL Connectors 4 Questions 5 Reference Information
Understanding Your Environment 2 You’ve got to be kidding!
Top demand programming languages 3 https://www.techworm.net/2017/02/top-9-demand-programming-languages-2017.html SQL Java Python Javascript C++ C# Perl iOS PHP
Understanding Your Environment 4 Understanding Your Environment - Install component in both Windows and Linux - PowerShell Open Source - Python 2.7 (By Default) or 3.x - Python Tcl/Tk packages - Python SQL Connectors - Use OneDrive - On Bash access (/mnt/c/Users/#username#/OneDrive) - On Linux access Windows shared folders
Understanding Your Environment 5 Understanding Your Environment - You're New to Linux - Go “Bash-On-Ubuntu-On-Windows” - Install "Ubuntu Desktop" - PowerShell - Python - Cross-Platform Editor - VS Code lightweight Multi-language editor - Other editors -Sublime -Brains PyCharm (Robust Python Editor Windows and Linux) *Use Windows Editors to create code
6 Demo 1
PowerShell and SQL Server 7 PowerShell and SQL Server - Connecting to SQL Server for scripting - Two ways: SQLPS module and SMO - Used only Windows Desktop (or Server) *Not possible on Linux systems - Access PowerShell from SSMS - Python with PowerShell for data collection - Possibility of Cross-platform solutions - Take advantage of .NET objects in Linux
PowerShell and SQL Server 8 PowerShell and SQL Server
PowerShell and SQL Server 9 PowerShell and SQL Server
Connecting to SQL Server with Python 10 Connecting to SQL Server with Python Choose a Python version Use “sudo Update-Alternatives” command # update-alternatives --list python - Two SQL Connectors - pyodbc - pymssql - Connectors Behavior - pyodbc and pymssql can connect to - Windows local and Multi-instance SQLServer - Linux only single instance
11 Demo 2 Connecting to SQL Server with PowerShell/Python.:
Reference Information 13 Reference Information PowerShell Open Source: https://github.com/PowerShell/PowerShell Windows PowerShell bugs use UserVoice: https://windowsserver.uservoice.com/forums/301869-powershell Python 3.5.2 (both Windows and Linux): https://www.python.org/download/releases/3.2.5/ Python Tcl/Tk: http://www.tcl.tk/ Python SQL Server ODBC connector (pyodbc): https://github.com/mkleehammer/pyodbc Python Microsoft SQL Server connector (pymssql): http://pymssql.org/en/stable/intro.html Bash for Windows 10: https://blogs.msdn.microsoft.com/commandline/learn-about-bash-on-windows-subsystem-for-linux/ https://blogs.msdn.microsoft.com/commandline/2016/11/17/do-not-change-linux-files-using-windows-apps-and-tools/ Python 3.6 Anaconda in SQL Server 2017: https://blogs.technet.microsoft.com/dataplatforminsider/2017/04/19/python-in-sql-server-2017-enhanced-in-database-machine-learning/ Microsoft blog - MVP Award program Blog: https://blogs.msdn.microsoft.com/mvpawardprogram/2017/05/26/friday-five-may-26th/?wt.mc_id=DX_883076 https://blogs.msdn.microsoft.com/mvpawardprogram/2017/03/10/friday-five-march-10th/ https://blogs.msdn.microsoft.com/mvpawardprogram/2017/02/17/friday-five-feb-17th/ https://blogs.msdn.microsoft.com/mvpawardprogram/2016/12/23/friday-five-dec-23/
12 Questions
Contact information: Maximo Trinidad Email: max_trinidad@Hotmail.com Twitter: @maxtrinidad