Installation guide
mxODBC - Python ODBC Database Interface
(a INTEGER,
rs OUT refcursor)
AS $$
BEGIN
OPEN rs FOR
SELECT a * 3;
END;
$$ LANGUAGE plpgsql;
5.6.6 SQL Output Statements in Stored Procedures
You should not use any output SQL statements such as "PRINT" in the stored
procedures, since this will cause at least some ODBC drivers (notably the MS SQL
Server one) to turn the output into an SQL error which causes the execution to
fail.
On the other hand, these error messages can be useful to pass along error
conditions to the Python program, since the error message string will be the
output of the
"PRINT" statement.
5.7 Introspection
5.7.1 Database Schema Introspection
mxODBC provides the full set of ODBC supported introspection cursor methods
which allows querying most database schema details without having to rely on
database specific internal system tables.
Usage is easy: Open a connection to the database, open a cursor on the
connection. Then call a catalog method on the cursor and inspect the generated
result set using the
cursor.fetch*() methods.
Please see section 7.6.1 Catalog Methods for full details on the available catalog
methods and their generated result sets.
5.7.2 Result Set Introspection
When working with dynamically generated SQL statements, you often need to
check the result set layout in order to prepare for processing the result set.
76