Date post: | 12-Apr-2017 |
Category: |
Software |
Upload: | idera-software |
View: | 63 times |
Download: | 0 times |
Using PowerShell with Python & SQL Server
February 22, 2017Maximo Trinidad
Python SQL Connectors
Understanding Your Environment
PowerShell and SQL Server
Questions3
12
4
1
Reference Information5
Understanding Your Environment
2
You’ve got to be kidding!
Top demand programming languageshttps://www.techworm.net/2017/02/top-9-demand-programming-languages-2017.html
1. SQL 2. Java3. Python4. Javascript5. C++6. C#7. Perl8. iOS 9. PHP
3
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
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
Demo 16
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
PowerShell and SQL Server
8
PowerShell and SQL Server
9
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
Demo 2Connecting to SQL Server with Python SQL connectors:-SQL Sample:Sampledb1SQLScript.sql
-Python Sample:QueryDataSample_pyodbc.pyQueryDataSample_pymssql.pyGuiSQLDataGrid01.pyReadCSVfileToGrid.pySampleMessageBox01.py
-PowerShell with Python :SamplePoshSQLPython2_Bash.ps1
11
Questions12
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/
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
Head over to IDERA.com to
download any of our product trials
free for 14-days.
Free Trials