--- title: "Functions" slug: "functions" updated: 2026-01-21T12:17:37Z published: 2026-01-21T12:17:37Z canonical: "docs.sightmachine.com/functions" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.sightmachine.com/llms.txt > Use this file to discover all available pages before exploring further. # Functions There are various functions available in the pre-installed `sm_udf` library for common use cases. ### Data Access #### Database `sm_udf.app_builder.odbc.get_sql_engine()` Returns a `sqlalchemy.engine.Engine` that is set up to connect to the database. Usage: ```python from sm_udf.app_builder.odbc import get_sql_engine() engine = get_sql_engine() with engine.connect() as conn:    conn.execute(sqlalchemy_query) ``` #### Sight Machine SDK `sm_udf.app_builder.smsdk.get_smsdk_client()` Returns an `smsdk.client.Client` that is set up to connect to the Sight Machine API. Usage: ```python from sm_udf.app_builder.smsdk import get_smsdk_client client = get_smsdk_client() ``` ### Output Formatting #### Graphs & Charts `sm_udf.app_builder.util.setup_plotly_theme()` Sets up a custom theme for [Plotly](https://plotly.com/python/) that matches the look and feel of other Sight Machine applications and dashboards. Usage: ```python from sm_udf.app_builder.util import setup_plotly_theme setup_plotly_theme() ``` #### Final Output `sm_udf.app_builder.util.return_app_builder_results(results)` Formats your results for final output. This is required to be the final line of the final cell in your notebook, and `results` must be a Python dictionary containing only JSON-serializable values. Usage: ```python from sm_udf.app_builder.util import return_app_builder_results return_app_builder_results(response) ``` #### Encode Page Linking for Markdown Panels `sm_udf.app_builder.util.create_markdown_encoded_data_link()` Help encode the `link_mapping` to pass to data-link for creating a link element in a markdown panel. Usage: ```python from sm_udf.app_builder.util import create_markdown_encoded_data_link link_encoded = create_markdown_encoded_data_link(link_mapping) markdown = f""" View Chart """ markdown_panel = {    "id": "markdown-panel",    "viz_type": "markdown",    "viz_props": {        "markdown": markdown    } } ```