This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Python SDK

The Vertica SDK supports writing UDxs of some types in Python 3.

The Vertica SDK supports writing UDxs of some types in Python 3.

The Python SDK does not require any additional system configuration or header files. This low overhead allows you to develop and deploy new capabilities to your Vertica cluster in a short amount of time.

The following workflow is typical for the Python SDK:

Because Python has an interpreter, you do not have to compile your program before loading the UDx in Vertica. However, you should expect to do some debugging of your code after you create your function and begin testing it in Vertica.

When Vertica calls your UDx, it starts a side process that manages the interaction between the server and the Python interpreter.

This section covers Python-specific topics that apply to all UDx types. For information that applies to all languages, see Arguments and return values, UDx parameters, Errors, warnings, and logging, Handling cancel requests and the sections for specific UDx types. For full API documentation, see the Python SDK.

1 - Python libraries

Before you can use your Python UDx, you need to verify that it meets the following library requirements:.

Before you can use your Python UDx, you need to verify that it meets the following library requirements:

  • Your UDx must import the vertica_sdk package in your code. You do not need to download this package. It is included as a part of the Vertica server.
    python import vertica_sdk
  • The Vertica Python SDK includes the Python Standard Library. If your UDx depends on other libraries, you must add them as dependencies using CREATE LIBRARY. You cannot simply import them.

2 - Python and Vertica data types

The Vertica Python SDK converts native Vertica data types into the appropriate Python data types, as follows:.

The Vertica Python SDK converts native Vertica data types into the appropriate Python data types, as follows:

Vertica Data Type Python Data Type
INTEGER int
FLOAT float
NUMERIC decimal.Decimal
DATE datetime.date
CHAR, VARCHAR, LONG VARCHAR string (UTF-8 encoded)
BINARY, VARBINARY, LONG VARBINARY binary
TIMESTAMP datetime.datetime
TIME datetime.time