Database Reference
In-Depth Information
TypeError: 'int' object does not support item
assignment
>>> a
1
>>> a = a[1] = 2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'int' object does not support item
assignment
>>> a
2
As you can see, it is possible that even a single multi-assignment statement can be
executed only halfway through. This means that you have to be be prepared to fully
manage your Python data yourself. The function, plpy.subtransaction() , won't
help you in any way with managing Python variables.
Debugging PL/Python
First, let's start by stating that there is no debugger support when running functions
in PL/Python; so it is a good idea to develop and debug a PL/Python function as a
pure Python function as much as possible and only do the final integration in PL/
Python. To help with this, you can have a similar environment in your Python devel-
opment environment using the plpy module.
Just put the module in your path and do import plpy before you try running
your prospective PL/Pythonu functions in an ordinary interpreter. If you use any
of the plpy.execute(...) or plpy.prepare() functions, you also need to
set up a database connection before using these by calling
plpy.connect(<connectstring>) .
Using plpy.notice() for tracking the function's progress
The debugging technology I use most often in any language is printing out intermedi-
ate values as the function progresses. If the printout rolls past too fast, you can slow
it down by sleeping a second or two after each print.
Search WWH ::




Custom Search