You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
insert_sql='INSERT INTO dbiEmployeesDatatypes (id, SMTH, BDATA) VALUES (?, ?, ?)'
56
+
foriinrange(1, 6):
57
+
dec_val=decimal.Decimal(f"{1000+i*0.5:.2f}")
58
+
blob_val=f"Blob data {i}".encode("utf-8")
59
+
cur.execute(insert_sql, (i, dec_val, blob_val))
60
+
61
+
dbi_conn.commit()
62
+
63
+
select_sql="SELECT * FROM dbiEmployeesDatatypes ORDER BY id"
64
+
65
+
# fetchall
66
+
cur.execute(select_sql)
67
+
all_rows=cur.fetchall()
68
+
print(self._format_blob_rows(all_rows))
69
+
70
+
# fetchmany(2)
71
+
cur2=dbi_conn.cursor()
72
+
cur2.execute(select_sql)
73
+
many_rows=cur2.fetchmany(2)
74
+
print(self._format_blob_rows(many_rows))
75
+
76
+
# fetchone
77
+
cur3=dbi_conn.cursor()
78
+
cur3.execute(select_sql)
79
+
one_row=cur3.fetchone()
80
+
# format fetchone single row as tuple (id, decimal, string)
81
+
id_, dec_val, blob_mv=one_row
82
+
blob_str=bytes(blob_mv).decode('utf-8')
83
+
print((id_, dec_val, blob_str))
84
+
85
+
86
+
#__END__
87
+
#__LUW_EXPECTED__
88
+
#[(1, Decimal('1000.50'), 'Blob data 1'), (2, Decimal('1001.00'), 'Blob data 2'), (3, Decimal('1001.50'), 'Blob data 3'), (4, Decimal('1002.00'), 'Blob data 4'), (5, Decimal('1002.50'), 'Blob data 5')]
89
+
#[(1, Decimal('1000.50'), 'Blob data 1'), (2, Decimal('1001.00'), 'Blob data 2')]
90
+
#(1, Decimal('1000.50'), 'Blob data 1')
91
+
#__ZOS_EXPECTED__
92
+
#[(1, Decimal('1000.50'), 'Blob data 1'), (2, Decimal('1001.00'), 'Blob data 2'), (3, Decimal('1001.50'), 'Blob data 3'), (4, Decimal('1002.00'), 'Blob data 4'), (5, Decimal('1002.50'), 'Blob data 5')]
93
+
#[(1, Decimal('1000.50'), 'Blob data 1'), (2, Decimal('1001.00'), 'Blob data 2')]
94
+
#(1, Decimal('1000.50'), 'Blob data 1')
95
+
#__SYSTEMI_EXPECTED__
96
+
#[(1, Decimal('1000.50'), 'Blob data 1'), (2, Decimal('1001.00'), 'Blob data 2'), (3, Decimal('1001.50'), 'Blob data 3'), (4, Decimal('1002.00'), 'Blob data 4'), (5, Decimal('1002.50'), 'Blob data 5')]
97
+
#[(1, Decimal('1000.50'), 'Blob data 1'), (2, Decimal('1001.00'), 'Blob data 2')]
98
+
#(1, Decimal('1000.50'), 'Blob data 1')
99
+
#__IDS_EXPECTED__
100
+
#[(1, Decimal('1000.50'), 'Blob data 1'), (2, Decimal('1001.00'), 'Blob data 2'), (3, Decimal('1001.50'), 'Blob data 3'), (4, Decimal('1002.00'), 'Blob data 4'), (5, Decimal('1002.50'), 'Blob data 5')]
101
+
#[(1, Decimal('1000.50'), 'Blob data 1'), (2, Decimal('1001.00'), 'Blob data 2')]
0 commit comments