John Liu Blog

Every drop counts

Setup R and Python on SQL Server 2022

When setup R or Python on SQL Server 2022, especially for named instance, some special notes required, apart from the offical documentation. You need to make sure when doing install, both Database Engine Services and Maching Learning Services and Language are installed. Unlike with earlier version of SQL, R and Python libraries are not installed/configured automatically in SQL 2022. You need to download and install latest R4.2. Then need to install some standard R dependencies.

Qt Designer notes

We use Qt Desinger to design QGIS plugin. Development Tools Install Plugin Builder (for creating Plugin project), Plugin Reloader (to refresh changes to the Plugin while developing) to assist with plugin development. Use Qt Designer to help create Plugin interface. When develope QGIS plugin, your source file folder and QGIS folder might be different. Instead of constantly copying files across, we can use Junction to creat symbolic link. Refer to the Readme.

Python cheatsheet

To find the Python installed pathes, under DOS command: where python In the Python interpreter, type following Python commands: import os import sys os.path.dirname(sys.executeable) or under DOS command: py -c "import os, sys; print(os.path.dirname(sys.executable))" To find the Python version, under DOS command: py --version py -V py -VV To create a dedicated environment. # from PowerShell / cmd python -m venv .env To use/activate the dedicated environment created above .\.env\Scripts\activate # PowerShell: .

QGIS get data from API

To retrieve data via API call in QGIS, we can utilise Python code to make the API call. Launch QGIS, open Plugins -> Python Console. In Python Console, click Show Editor icon to open editor. In editor window, make new script or open the Python script and execute the Python script. Following is an example Python script to make API call. ##If keyring is not installed, run the following in QGIS Python console to install keyring.

SQL Server Run Different Version of Python

SQL Server Machine Learning Service comes with a default Phyton runtime. For SQL 2019, it’s Phyton 3.5. You might need to run your Phyton script against a different version of Phyton runtime. To configure another Phyton version runtime to be available to your SQL instance, do the following: Install Phyton 3.10 with options to install for all users Install required packages Grant required permissions to SQL Server LaunchPad service @ECHO OFF ECHO installing python "%~dp0python-3.