You can watch the replay for this Geek Sync webcast in the IDERA Resource Center: http://ow.ly/Mf3H50A5dMC
Just as PowerShell is argued as the main technology for automation in Windows Datacenters Infrastructure, it is equally important in other non-Windows Operating Systems. According to Maximo Trinidad, Windows Administrators have an advantage working with PowerShell just as Linux Administrators have an advantage with Bash / PHP / Python.
Join IDERA and Maximo Trinidad as he walks you through using PowerShell with both SQL Server and Python. This Geek Sync will be interactive and very demo intensive. Questions are encouraged!
About Maximo Trinidad: In Florida, Maximo is known as Mr. PowerShell. He is the founder of the Florida PowerShell User Group which meets on a monthly basis. Maximo is originally from Puerto Rico and has been working in the technology world since 1979. Over the years, he has worked with SQL Server Technologies, provided support to Windows Servers/Client machines, Microsoft Virtualization Technologies, and built some Visual Studio solutions. He has been a Microsoft PowerShell MVP since 2009 and MVP SAPIEN Technologies 2015. He speaks at many of the SQLSaturdays, IT Pro and .NET camps events around Florida.
5. 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
4
6. 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
5
8. 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
7
11. 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 Behaviour
- pyodbc and pymssql can connect to
- Windows local and Multi-instance SQLServer
- Linux only single instance
10
12. Demo 2
Connecting to SQL Server with Python SQL connectors:
-SQL Sample:
Sampledb1SQLScript.sql
-Python Sample:
QueryDataSample_pyodbc.py
QueryDataSample_pymssql.py
GuiSQLDataGrid01.py
ReadCSVfileToGrid.py
SampleMessageBox01.py
-PowerShell with Python :
SamplePoshSQLPython2_Bash.ps1
11
14. Reference
Information
13
PowerShell Open Source: https://github.com/PowerShell/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
MaxtBlog post “Windows 10 Bash and PowerShell Redux”: http://www.maxtblog.com/2017/01/windows-10-bash-
and-powershell-redux/
Bash for Windows 10: https://blogs.msdn.microsoft.com/commandline/learn-about-bash-on-windows-subsystem-
for-linux/
*Important link: https://blogs.msdn.microsoft.com/commandline/2016/11/17/do-not-change-linux-files-using-
windows-apps-and-tools/
15. Don’t forget to check out the
previously recorded Geek Sync
webcasts to learn more about
PowerShell and SQL Server.
Thank You!
https://www.idera.com/events/geeksync