import com.ziclix.python.sql.zxJDBC as zxJDBC
# In place of this, imagine a complicated query returning multiple ResultSet instances.
fancyApiCursorQuery = 'SELECT MyColumn FROM MyTable'
url='jdbc:sqlserver://sqlserver-host:1433;database=MyBigDatabase'
user='mario'
pw='myP@ssw0rd'
driver='com.microsoft.sqlserver.jdbc.SQLServerDriver'
conn = zxJDBC.connect(url, user, pw, driver)
try:
# We're going to have to use the JDBC connection directly for this fancy stuff.
jdbcConn = conn.__connection__
stmt = jdbcConn.createStatement()
stmt.execute(fancyApiCursorQuery)
rs = None
while True:
# Loop through the set of ResultSet objects.
rs = stmt.getResultSet()
while rs.next():
print rs.getString('MyColumn')
if stmt.getMoreResults() == False and stmt.getUpdateCount() == -1:
# We have no more ResultSet objects.
break
if rs:
rs.close()
stmt.close()
finally:
if conn:
conn.close()