Overview
Python is an interpreted, interactive, object-oriented programming language. It incorporates modules, exceptions, dynamic typing, very high level dynamic data types, and classes. Python has packages that encapsulates different categories of functionality in libraries (also called packages). For applying the statistical analysis one often needs sample data. Assuming that we already have sample datasets at hand, we can use Python for analyzing the statistical computations and algorithms. To develop these computations, one needs to know regular programming constructs like variables, data types, operators, loops, etc.
Explanation
Most of the programming constructs that are available in Python are also available in T-SQL. Our intention is not to learn Python in full detail, but to learn Python constructs that enable us to consume the unique Python libraries and data processing / computation mechanisms that are not available in T-SQL. In this lesson we will be learning the basic concepts of Python, just sufficient enough for us to apply Python functions and packages, so that we can apply the concepts for the data passed from the SQL Server data repository.
Python version, packages and datasets
We already learned in the last lesson how to check the version of Python runtime that the database engine is communicating. It necessary to know the version of Python you are working with, as that can be considered as the basis of what is supported by a particular version of Python. Using the sp_execute_external_script, with a simple Python property “sys.version”, we can check the details of Python version as shown below. Print function prints the output on the SQL Server Management Studio (SSMS) message console. In this lesson our focus is developing the fundamentals of Python. We will discuss the details of sp_execute_external_script in the next lesson. Until then just consider this procedure as execution wrapper.
The next step is to explore the different libraries available with Python installation by default. You can explore them from here. You can load any given library by using the import function. We already looked at an example of the use of this function in the above code.
Post a Comment