Hello, brand new to Universe and trying to learn the basics of using Python to interact with the Universe database.
I’m using the RESTful Web Services to call a Basic subroutine:
SUBROUTINE createBook ( BookDetails, ErrText, pyresult ) pymodule = PyImport("createBook") pyresult = PyCallFunction("createBook", "create_book", BookDetails) RETURN
Here is a simplified version of the Python code (createBook.py):
def create_book(book_details) import u2py last_id = u2py.Command("SELECT MAX(ID) FROM U2_BOOKS;").run() return str(last_id)
I get an error on the line with the Command and run:
error creating U2Error (10252) unknown Traceback (most recent call last): File "C:\U2\UV\incubator\u2_books\BOOKS_PP\createBook.py", line 4, in create_book last_id = u2py.Command("SELECT MAX(ID) FROM U2_BOOKS;").run() File "C:\U2\UV\bin\u2py.py", line 85, in run super().run() u2py.U2Error: (10252) unknown
I get this error with any sort of SQL statement (e.g. “SELECT U2_BOOKS FIRST 10;”). However, if I change the command to something else (like “WHO”) it works fine.
I’ve tested out the SQL statement and it works fine if I run it from the U2 Python shell command prompt. It also works if I just put it into a simple python script and run it from the U2 shell using RUNPY command. But for some reason I’m getting this unknown error when running it from a Basic subroutine.