Skip to content

Cannot create UDF using python language #105

@hag0r

Description

@hag0r

I am trying to create user defined functions in Python. From the MonetDB blog I found how to create functions for Python. I modified the getstarted.py script of monetdb-examples:

conn = monetdbe.connect(':memory:')
c = conn.cursor()
c.execute("CREATE TABLE integers(i INTEGER, j INTEGER);")
c.execute("INSERT INTO integers VALUES (3, 4), (5, 6), (7, 8);")
c.execute("CREATE or replace FUNCTION myadd(a integer, b integer) returns integer language python { return a+b };")
c.execute("SELECT myadd(i,j) FROM integers")

However, it seems that the Python support is not activated via MonetDBe:

$ python getstarted.py 
MALException:multiplex:42000!Error in optimizer multiplex: TypeException:user.s6_0[16]:'pyapi3.eval' library error in: Embedded Python 3 has not been enabled. Start server with --set embedded_py=3

Traceback (most recent call last):
  File "getstarted.py", line 25, in <module>
    c.execute("SELECT myadd(i,j) FROM integers")
  File "/home/hage/.local/lib/python3.8/site-packages/monetdbe/cursor.py", line 152, in execute
    self.result, self.rowcount = self.connection.lowlevel.query(formatted, make_result=True)  # type: ignore
  File "/home/hage/.local/lib/python3.8/site-packages/monetdbe/_cffi.py", line 246, in query
    check_error(lib.monetdbe_query(self._connection, query.encode(), p_result, affected_rows))
  File "/home/hage/.local/lib/python3.8/site-packages/monetdbe/_cffi.py", line 82, in check_error
    raise exception(msg)
monetdbe.exceptions.OperationalError: Error in optimizer multiplex: TypeException:user.s6_0[16]:'pyapi3.eval' library error in: Embedded Python 3 has not been enabled. Start server with --set embedded_py=3

However, I cannot find a way to set this embedded_py since I'm not starting any server. What am I missing ?

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions