Please take this survey to help us learn more about how you use third party tools. Your input is greatly appreciated!

Why vertica queries can be run from JavaUdx but not from PythonUdx?

I have a java based udx function which connects to vertica (9.2.x) and execute queries but the same thing in python is not working. I am using "vertica_python" package and since it generates .egg file , i am end up getting imprort vertica_python error. Need help!!

Best Answer

  • priteshpritesh
    Accepted Answer

    Ok, so my file looks like this.
    import vertica_python
    conn_info = { XXXXX }
    connection = vertica_python.connect(**conn_info)
    db_cursor = connection.cursor()

    class test_datatypes(vertica_sdk.ScalarFunction):
    """Testing If Vertica Queries Can be Run From Here Returns None """
    def init(self):
    def setup(self, server_interface, col_types):
    def processBlock(self, server_interface, arg_reader, res_writer):
    server_interface.log(" $$$ ")
    fn = arg_reader.getString(0)
    t_name = arg_reader.getString(1)
    q = """ Insert Query """
    res_writer.setString("File Name : "+fn + ", Table Name : " + t_name)
    if not

    def destroy(self, server_interface, col_types):

    class test_datatypes_factory(vertica_sdk.ScalarFunctionFactory):
    def createScalarFunction(self, srv):
    return test_datatypes()
    def getPrototype(self, srv_interface, arg_types, return_type):
    def getReturnType(self, srv_interface, arg_types, return_type):

    This is how my .py file looks like. I am just trying to run query inside (taking random params as of now--ignorable)
    Creating Libs Here:
    CREATE LIBRARY test_datatypes_lib AS '/test/user/' DEPENDS '/test/user/site-packages/' LANGUAGE 'Python';
    CREATE FUNCTION test_datatypes AS LANGUAGE 'Python' NAME 'test_datatypes_factory' LIBRARY test_datatypes_lib;


  • SruthiASruthiA Employee

    Can you share me more details? If you can please share me your python UDx

  • Bryan_HBryan_H Employee

    Hi, you should be able to run Vertica queries using the recent driver from Github that works on Python 3.x:
    Is there a specific error from your code? Did you try the sample code from the Github README?

  • thanks for the answer, but as i have already pasted the code above, i am using the recent drive and i have also tried "vertica_db_client" python client driver section. The package that you mentioned upon installing generates a .egg file, which can not be imported, the error looks straight "**import error --> not found". i have posted you discussion please see that also. 'Vertica v9.2.0-7 Jdbc Driver for Python2.7(.x) but same doesn't support Python2.7?'

  • Thanks @Bryan_H , your solution worked. Thanks a lot !!

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file

Can't find what you're looking for? Search the Vertica Documentation, Knowledge Base, or Blog for more information.