The three core components of mssql-scripter are:
- Python Client
- Scripting Service
- SqlScriptPublishModel
The Python client is script that orchestrates the scripting operation. It's responsible for:
- Parsing the command line options
- Starting the SqlToolsService process
- Issuing the scripting request to the Scripting Service
- Responding to the Scripting Service events which report progress and completion
- Piping the script results to STDIO
The Scripter Service is hosted by the SqlToolsService, which is itself a self-contained .NET Core console application. The Scripting Service is responsible for:
- Exposing the JSON-RPC endpoint to handle scripting requests
- Instantiating the SqlScriptPublishModel to execute a scripting request
- Forwarding events from the SqlScriptPublishModel to clients over JSON-RPC
The SqlToolsService is used by other cross platform SQL tools, such as the Microsoft/vscode-mssql extension. The SqlToolsService is an open source project and hosted on github at Microsoft/sqltoolsservice.
The SqlScriptPublishModel is the component used by the Scripting Service to drive the scripting operation. It uses the SQL Server Management Objects (SMO) framework, to generate the underlying scripts for database. It's responsible for:
- Running the scripting operations using SMO
- Send progress events as the scripting operation makes progress
The SQL Server Management Objects library is designed for programmatic management of SQL Server. One of the many features it provides is scripting interface. SMO can be used to discover dependencies, understand the relationships between objects, and generate a .sql script that can re-create the objects in a database.
The SqlScriptPublishModel and SMO are the same components used by the Scripting Wizard in SQL Server Management Studio (SSMS).