Pre-General Availability: 2023-11-20
If you write a Python application anywhere in Visual Studio Code, and if any of the Python strings within the application contain SQL code, you can establish a link between the string containing the SQL code (indicated by orange arrow-like icons) and the code block of a separate DB Notebook. Changes made in the notebook editor can be sent back to the original SQL code, as long as the Python string it originated from remains unchanged.
Essentially, this feature enables you to write a Python application and to test the embedded SQL code by executing it in a DB Notebook where you can then fix SQL syntax errors, check the actual result, and test different parameters before running the Python application.
Highlight the embedded SQL.
Right-click and select Execute Embedded SQL with MySQL Shell from the menu.
When prompted, type (or select) an existing database connection to use.
The SQL statements are executed and outputted to a new code block in the notebook editor of the connection you selected.
Right-click the statement and select Update SQL in Original Source File. The edited SQL statement is returned to the original code block and replaces the original SQL statement.