How to: Import and use libraries in Jinja2

Oomnitza uses the Jinja2 templating language allow for a diverse array of transformations in order to better facilitate data management and hygeine, as well as complex functions and data transformations.

To allow for the widest possible array of data manipulation, Oomnitza's Jinja2 functionality also allows you to import libraries to perform even more complex functions. 

For security reasons, Oomnitza limits this to the following libraries:

These Libraries are Python Standard Libraries, and the full list of commands for each can be found here, or in the links above:

Using the Libraries

These Libraries can be imported and utilized in your Jinja2 Commands using the following syntax:

{% set datetime = import('datetime') %}

This will provide you with an object that can be used in downstream functions in your Jinja2 Command. For example, using the datetime library, we can calculate the age of a data field, or determine the difference between two date fields:

{% set datetime = import('datetime') %}{% set age = (datetime.datetime.utcnow|to_datetime - date_field|to_datetime).days %}{{age}}

For any questions or assistance with setting up Jinja2 commands or using libraries, please reach out to

Have more questions? Submit a request


Please sign in to leave a comment.
Powered by Zendesk