diff --git a/Content/liquibase-pro/policy-checks/custom-policy-checks/liquibase-api-python-modules.htm b/Content/liquibase-pro/policy-checks/custom-policy-checks/liquibase-api-python-modules.htm index 2c4330437..999382621 100644 --- a/Content/liquibase-pro/policy-checks/custom-policy-checks/liquibase-api-python-modules.htm +++ b/Content/liquibase-pro/policy-checks/custom-policy-checks/liquibase-api-python-modules.htm @@ -220,8 +220,8 @@
liquibase_utilities
Returns the SQL associated with this change that
) it finds. Otherwise, it generates SQL from any modeled
) it finds, similar to running the
command.
Does not include
Example:
changes = liquibase_utilities.get_changes() # get the changes we're looking at
-sql = liquibase_utilities.generate_sql(change[0]) # get the first change in the list
+ Example:
changes = liquibase_utilities.get_changes()
+sql = liquibase_utilities.generate_sql(change[0])
if "something bad" in sql:
status.fired = True
sys.exit(1) # exit from the check
diff --git a/Content/liquibase-pro/policy-checks/custom-policy-checks/sample-scripts.htm b/Content/liquibase-pro/policy-checks/custom-policy-checks/sample-scripts.htm
index 1b446a547..5963a3cb2 100644
--- a/Content/liquibase-pro/policy-checks/custom-policy-checks/sample-scripts.htm
+++ b/Content/liquibase-pro/policy-checks/custom-policy-checks/sample-scripts.htm
@@ -22,8 +22,8 @@ modules
For a list of modules and functions you can call on, see [%=General.Liquibase%] API Python Modules .
Python libraries
- If you're new to Python, read the official Python tutorial before writing any scripts. See Python Standard Library for information on built-in functions. You can always import these at the beginning of your script.
- comes pre-installed with a GraalPy virtual environment. In addition to the built-in modules, the built-in virtual environment contains the following Python modules that aren't part of the Python Standard Library:
+ If you're new to Python, read the official Python tutorial before writing any scripts. See the Python Standard Library for information on built-in functions. You can always import these at the beginning of your script.
+ comes pre-installed with a GraalPy virtual environment. In addition to the built-in modules, this virtual environment contains the following Python modules that aren't part of the Python Standard Library:
However, you cannot install additional modules in the built-in virtual environment because it is packaged in the checks extension JAR file. To install additional modules, you must create your own virtual environment and install them yourself, including a package containing the API. For more information, see Create a Python Virtual Environment .
Looping behavior
@@ -34,12 +34,12 @@ Looping behavior
If you write a custom policy check that is individually performance-heavy, and you have a very large or database, may take a long time to run your custom check against all objects.
Script status
- Your Python script doesn't need to return a value. uses a Status
object to track the state of your check:
+ Your Python script doesn't need to return a value. uses an object called Status
to track the state of your check:
- Whether the check has triggered (fired)
- The message to display as output
- At the point in your script where the check should trigger, use the liquibase_utilities
to modify the Status
object:
if [trigger condition]:
+ At the point in your script where the check should trigger, use the liquibase_utilities
module to modify the Status
object:
if [trigger condition]:
liquibase_utilities.get_status().fired = True
liquibase_utilities.get_status().message = liquibase_utilities.get_script_message()
sys.exit(1)
@@ -55,9 +55,9 @@ Script status
Sample scripts
# This script checks for the phrase "DELETE FROM" without "WHERE"