SqlEngine.registerFunction

Register a function to be accessible to this SqlEngine.

For an overview see page Python SqlEngine Class

Prototype

 
    SqlEngine.registerFunction(return_type, function_name, function, n_arguments)
 

Arguments

return_type

The return type; one of the following built-in Python types:

 
    bool
    int
    long
    float
    string
    unicode
 
function_name

The function name

function The Python function as defined by the application and registered with the runtime by calling exdb.register_function()
n_arguments The number of arguments for this function; if -1 is specified it means that the function accepts a variable number of arguments

Description

When a function is registered using this method, it will be accessible to this SqlEngine.

NB: This method is reentrant. In the current Python API a SqlEngine is implicitly created by a cursor, so this method is rarely needed. Also please note the following:

Returns

Exception An exception is thrown with the appropriate error message

Example

     
    def ema(agg,val):
        a = 2.0 / (14 + 1)
        return a*val + (1-a)*agg
 
    ...
    dict = exdb.load_dictionary(schema, persistent=is_disk, debug=is_debug)
    db = exdb.open_database(dbname='opendb', dictionary=dict, is_disk=is_disk, db_segment_size=128*1024*1024);
    exdb.register_function(float, "ema", ema, 2)
    ...
    conn = db.connect()
    conn.engine.registerFunction(float, "ema", ema, 2)