code: def prepare_connection(conn, database, datasette):
      def convert_units(amount, from_, to_):
          """select convert_units(100, 'm', 'ft');"""
          return (amount * ureg(from_)).to(to_).to_tuple()[0]
  
      conn.create_function("convert_units", 3, convert_units)
  
      def prepare_connection_args():
          return 'database={}, datasette.plugin_config("name-of-plugin")={}'.format(
              database, datasette.plugin_config("name-of-plugin")
          )
  
      conn.create_function(
          "prepare_connection_args", 0, prepare_connection_args
      )
  
imports: import asyncio
  from datasette import hookimpl, Permission
  from datasette.facets import Facet
  from datasette import tracer
  from datasette.utils import path_with_added_args
  from datasette.utils.asgi import asgi_send_json, Response
  import base64
  import pint
  import json
label_desc: Use image node_id 1 for calling a global function with example usage: prepare_connection(conn, database, datasette) and returns: unknown, str