set_session_param() | Database Utilities | Teradata Python Package - set_session_param() - Teradata Package for Python

Teradata® Package for Python User Guide

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Teradata Package for Python
Release Number
20.00
Published
December 2024
ft:locale
en-US
ft:lastEdition
2025-01-23
dita:mapPath
nvi1706202040305.ditamap
dita:ditavalPath
plt1683835213376.ditaval
dita:id
rkb1531260709148
lifecycle
latest
Product Category
Teradata Vantage
Use the set_session_param() function to set the database session parameters. Returns True if session parameter is set successfully.
Refer to "SET SESSIONS" in , B035-1144 for session parameters.

Raises ValueError, teradatasql.OperationalError

Required arguments:
  • name specifies the name of the parameter to set.

    Permitted values: timezone, calendar, account, character_set_unicode, collation, constraint, database, dateform, debug_function, dot_notation, isolated_loading, function_trace, json_ignore_errors, searchuifdbpath, transaction_isolation_level, query_band, udfsearchpath

    Types: str

  • value specifies the value for the parameter "name" to set.
    Permitted values:
    • timezone: timezone strings
    • calendar: Teradata, ISO, Compatible
    • character_set_unicode: ON, OFF
    • account: should be a list in which first item should be "account string" second should be either SESSION or REQUEST.
    • collation: ASCII, CHARSET_COLL, EBCDIC, HOST, JIS_COLL, MULTINATIONAL
    • constraint: row_level_security_constraint_name {( level_name | category_name [,...] | NULL )}
      where:
      • row_level_security_constraint_name: Name of an existing constraint.

        The specified constraint_name must be currently assigned to the user. You can specify a maximum of 6 hierarchical constraints and 2 non-hierarchical constraints per SET SESSION CONSTRAINT statement.

      • level_name: Name of a hierarchical level, valid for the constraint_name, that is to replace the default level.

        The specified level_name must be currently assigned to the user. Otherwise, Vantage returns an error to the requestor.

      • category_name: A set of one or more existing non-hierarchical category names valid for the constraint_name.

        Because all assigned category (non-hierarchical) constraint values assigned to a user are automatically active, "set_session_param" is only useful to specify a subset of the assigned categories for the constraint.

        For example, assume that User BOB has 3 country codes, and wants to load a table with data that is to be made available to User CARL who only has rights to see data for his own country. User BOB can use "set_session_param" to specify only the country code for User CARL when loading the data so Carl can access the data later.

    • database: Name of the new default database for the remainder of the current session.
    • dateform: ANSIDATE, INTEGERDATE
    • debug_function: Specifies a list in which the first item is "function_name" and second item is either ON or OFF.
    • dot_notation: DEFAULT, LIST, NULL ERROR
    • isolated_loading: NO, '', CONCURRENT
    • function_trace: Specifies a list in which the first item is "mask_string" and second is the table name.
    • json_ignore_errors: ON, OFF
    • searchuifdbpath: String in format 'database_name, user_name'
    • transaction_isolation_level: READ UNCOMMITTED, RU, SERIALIZABLE, SR
    • query_band: Should be a list first item should be "band_specification" and second should be either SESSION or TRANSACTION.
    • udfsearchpath: Should be a list first item should be "database_name" and second should be "udf_name".

    Types: str or list of strings

Example 1: Set time zone offset for the session as the system default

>>> set_session_param('timezone', "'LOCAL'")
True

Example 2: Set time zone to "AMERICA PACIFIC"

>>> set_session_param('timezone', "'AMERICA PACIFIC'")
True

Example 3: Set time zone to "-07:00"

>>> set_session_param('timezone', "'-07:00'")
True

Example 4: Set time zone to 3 hours ahead of 'GMT'

>>> set_session_param('timezone', "3")
True

Example 5: Set calendar to 'COMPATIBLE'

>>> set_session_param('calendar', "COMPATIBLE")
True

Example 6: Dynamically change account to 'dbc' for remainder of session

>>> set_session_param('account', ['dbc', 'SESSION'])
True

Example 7: Enable Unicode Pass Through processing

>>> set_session_param('character_set_unicode', 'ON')
True

Example 8: Set session to ASCII collation

>>> set_session_param('collation', 'ASCII')
True

Example 9: Resulting session has row-level security label consisting of unclassified level and nato category

>>> set_session_param('constraint', 'classification_category (norway)')
True

Example 10: Change default database for the session

>>> set_session_param('database', 'alice')
True

Example 11: Change the DATE format to 'INTEGERDATE'

>>> set_session_param('dateform', 'INTEGERDATE')
True

Example 12: Enable debugging for the session

>>> set_session_param('debug_function', ['function_name', 'ON'])
True

Example 13: Set session response for dot notation query result

>>> set_session_param('dot_notation', 'DEFAULT')
True

Example 14: DML operations are not performed as concurrent load isolated operation

>>> set_session_param('isolated_loading', 'NO')
True

Example 15: Enable function trace output for debugging external user-defined functions and external SQL procedures for current session

>>> set_session_param('function_trace', ["'diag,3'", 'titanic'])
True

Example 16: Enable validation of JSON data on INSERT operations

>>> set_session_param('json_ignore_errors', 'ON')
True

Example 17: Set database search path for SCRIPT execution in SessionTbl.SearchUIFDBPath column

>>> set_session_param('SEARCHUIFDBPATH', 'dbc, alice')
True

Example 18: Use PROXYROLE name:value pair in a query band to set proxy role in a trusted session to a specific role

>>> set_session_param('query_band', ["'PROXYUSER=fred;PROXYROLE=administration;'", 'SESSION'])
True

Example 21: Specify custom UDF search path

When you run a UDF, Analytics Database searches this path first, before looking in the default Analytics Database search path for the UDF.

>>> set_session_param('udfsearchpath', ["alice, SYSLIB, TD_SYSFNLIB", 'bitor'])
True