+ 2

how to connect DB2 with Python

required information how to connect a windows based DB2 system with python. I need to create a repository of tables with an online screen. any help really appreciated

14th Mar 2018, 3:17 PM
Arun Chiriyankandath
Arun Chiriyankandath - avatar
1 ответ
+ 2
>>> import DB2 >>> conn = DB2.connect(dsn='sample', uid='db2inst1', pwd='******') >>> curs = conn.cursor() >>> curs.execute('SELECT * FROM ORG') >>> rows = curs.fetchall() >>> rows [('A00', 'SPIFFY COMPUTER SERVICE DIV.', '000010', 'A00', None), ('B01', 'PLANNING', '000020', 'A00', None), ('C01', 'INFORMATION CENTER', '000030', 'A00', None), ('D01', 'DEVELOPMENT CENTER', None, 'A00', None), ('D11', 'MANUFACTURING SYSTEMS', '000060', 'D01', None), ('D21', 'ADMINISTRATION SYSTEMS', '000070', 'D01', None), ('E01', 'SUPPORT SERVICES', '000050', 'A00', None), ('E11', 'OPERATIONS', '000090', 'E01', None), ('E21', 'SOFTWARE SUPPORT', '000100', 'E01', None), ('F22', 'BRANCH OFFICE F2', None, 'E01', None), ('G22', 'BRANCH OFFICE G2', None, 'E01', None), ('H22', 'BRANCH OFFICE H2', None, 'E01', None), ('I22', 'BRANCH OFFICE I2', None, 'E01', None), ('J22', 'BRANCH OFFICE J2', None, 'E01', None)] >>> curs.close() >>> conn.close()
16th Mar 2018, 5:28 PM
Baraa AB
Baraa AB - avatar