On ons, 2012-04-11 at 12:48 -0700, Chris Clark wrote: > > rv = plpy.execute("some SQL command") > > if rv.colnames() is not None: > > output(rv.colnames()) > > else: > > output("it's a utility command") > > My 2 cents, I don't like any of them :-p > > I prefer the last one modified slightly: > > rv = plpy.execute("some SQL command") > if rv.colnames(): > output(rv.colnames()) > else: > output("it's a utility command") > > I.e. loose the None check.
That would misbehave if a result set exists but contains zero columns. (Sounds strange, but it's possible.) Which actually now makes me lean toward throwing an exception. > I'm not sure I like making an explicit > function call for the colnames. I.e. I think sticking with the pep249 > description attribute is a better solution, the API already exist so > clone that (when possible) in your new api. That would require populating this structure on every call, which would be expensive for such a low-level API, or turning the attribute into a fake function, which would be evil. I think this is best left to the plpydbapi layer on top of it. _______________________________________________ DB-SIG maillist - DB-SIG@python.org http://mail.python.org/mailman/listinfo/db-sig