Home > Blockchain >  how to get AzSql Database Import/Export Status using Python
how to get AzSql Database Import/Export Status using Python

Time:07-12

I am trying to import a bacpac to azure sql database it runs for almost 2.5 hours, I need to get the status of this import job i.e. in-progress, complete etc using python. I know I can do it using Get-AzSqlDatabaseImportExportStatus -OperationstatusLink in powershell, but I want to do this using python.

CodePudding user response:

You can use Python's subprocess module to run Powershell commands.

The subprocess module allows you to spawn new processes, connect to their input/output/error pipes, and obtain their return codes.

You can store the Powershell script in any file and then read that file using subprocess.Popen method.

Example:

import subprocess, sys

p = subprocess.Popen(["powershell.exe", 
              "C:\\Project\\downloadSharePointFile.ps1"], 
              stdout=sys.stdout)
p.communicate()

Refer: Running Powershell script with Python, Executing PowerShell from Python

  • Related