forked from ibmdb/python-ibmdb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support Python 3.13 and add fetch APIs (fetchone, fetchmany, fetchall) (
ibmdb#971) Signed-off-by: Balram Choudhary <[email protected]>
- Loading branch information
1 parent
87e2e35
commit 148866a
Showing
7 changed files
with
377 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# | ||
# Licensed Materials - Property of IBM | ||
# | ||
# (c) Copyright IBM Corp. 2007-2008 | ||
# | ||
|
||
from __future__ import print_function | ||
import sys | ||
import unittest | ||
import ibm_db | ||
import config | ||
from testfunctions import IbmDbTestFunctions | ||
|
||
class IbmDbTestCase(unittest.TestCase): | ||
|
||
def test_312_FetchOne(self): | ||
obj = IbmDbTestFunctions() | ||
obj.assert_expect(self.run_test_312) | ||
|
||
def run_test_312(self): | ||
conn = ibm_db.connect(config.database, config.user, config.password) | ||
|
||
ibm_db.autocommit(conn, ibm_db.SQL_AUTOCOMMIT_OFF) | ||
|
||
# Drop the test table, in case it exists | ||
drop = 'DROP TABLE animals' | ||
try: | ||
result = ibm_db.exec_immediate(conn, drop) | ||
except: | ||
pass | ||
|
||
# Create the test table | ||
create = 'CREATE TABLE animals (id INTEGER, breed VARCHAR(32), name VARCHAR(16), weight DECIMAL(7,2))' | ||
result = ibm_db.exec_immediate(conn, create) | ||
|
||
insert = "INSERT INTO animals values (0, 'cat', 'Pook', 3.2)" | ||
ibm_db.exec_immediate(conn, insert) | ||
|
||
insert = "INSERT INTO animals values (1, 'dog', 'Max', 12.5)" | ||
ibm_db.exec_immediate(conn, insert) | ||
|
||
insert = "INSERT INTO animals values (2, 'parrot', 'Polly', 0.8)" | ||
ibm_db.exec_immediate(conn, insert) | ||
|
||
insert = "INSERT INTO animals values (3, 'rabbit', 'Bunny', 2.3)" | ||
ibm_db.exec_immediate(conn, insert) | ||
|
||
insert = "INSERT INTO animals values (4, 'hamster', 'Nibbles', 0.5)" | ||
ibm_db.exec_immediate(conn, insert) | ||
|
||
insert = "INSERT INTO animals values (5, 'fish', 'Bubbles', 0.2)" | ||
ibm_db.exec_immediate(conn, insert) | ||
|
||
insert = "INSERT INTO animals values (6, 'snake', 'Slither', 1.1)" | ||
ibm_db.exec_immediate(conn, insert) | ||
|
||
insert = "INSERT INTO animals values (7, 'horse', 'Thunder', 450.7)" | ||
ibm_db.exec_immediate(conn, insert) | ||
|
||
stmt = ibm_db.exec_immediate(conn, "select * from animals") | ||
|
||
onerow = ibm_db.fetchone(stmt) | ||
|
||
print(onerow) | ||
|
||
ibm_db.rollback(conn) | ||
|
||
#__END__ | ||
#__LUW_EXPECTED__ | ||
#(0, 'cat', 'Pook', '3.20') | ||
#__ZOS_EXPECTED__ | ||
#(0, 'cat', 'Pook', '3.20') | ||
#__SYSTEMI_EXPECTED__ | ||
#(0, 'cat', 'Pook', '3.20') | ||
#__IDS_EXPECTED__ | ||
#(0, 'cat', 'Pook', '3.20') |
Oops, something went wrong.