From 52f4e7090c76dfeb3de1081f9838e858ab11fc66 Mon Sep 17 00:00:00 2001 From: Anthony Tuininga Date: Fri, 18 May 2018 14:24:52 -0600 Subject: [PATCH] Rename sample and adjust documentation in sample to clarify use. --- .../{ReturnLongs.py => ReturnLobsAsStrings.py} | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) rename samples/{ReturnLongs.py => ReturnLobsAsStrings.py} (81%) diff --git a/samples/ReturnLongs.py b/samples/ReturnLobsAsStrings.py similarity index 81% rename from samples/ReturnLongs.py rename to samples/ReturnLobsAsStrings.py index b681029..b6f1164 100644 --- a/samples/ReturnLongs.py +++ b/samples/ReturnLobsAsStrings.py @@ -1,5 +1,5 @@ #------------------------------------------------------------------------------ -# Copyright 2016, 2017, Oracle and/or its affiliates. All rights reserved. +# Copyright 2016, 2018, Oracle and/or its affiliates. All rights reserved. # # Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved. # @@ -8,11 +8,12 @@ #------------------------------------------------------------------------------ #------------------------------------------------------------------------------ -# ReturnLongs.py -# Returns all CLOB values as long strings and BLOB values as long raws. This -# is only useful if the lengths of the CLOB and BLOB values are well known but -# it can improve performance because there is no need to return to the database -# to get the actual values. +# ReturnLobsAsStrings.py +# Returns all CLOB values as strings and BLOB values as bytes. The +# performance of this technique is significantly better than fetching the LOBs +# and then reading the contents of the LOBs as it avoids round-trips to the +# database. Be aware, however, that this method requires contiguous memory so +# is not usable for very large LOBs. # # This script requires cx_Oracle 5.0 and higher. #------------------------------------------------------------------------------ @@ -49,7 +50,7 @@ for i in range(10): connection.commit() # fetch the data and show the results -print("CLOBS returned as longs") +print("CLOBS returned as strings") cursor.execute(""" select IntCol, @@ -59,7 +60,7 @@ cursor.execute(""" for intCol, value in cursor: print("Row:", intCol, "string of length", len(value)) print() -print("BLOBS returned as longs") +print("BLOBS returned as bytes") cursor.execute(""" select IntCol,