-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsystem_info_module.py
More file actions
30 lines (26 loc) · 962 Bytes
/
Copy pathsystem_info_module.py
File metadata and controls
30 lines (26 loc) · 962 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import ibm_db
def get_system_info(conn_str):
try:
# Connect to the database
conn = ibm_db.connect(conn_str, "", "")
if conn:
print("Connected to the database.")
# Execute SQL query to select entries from SYSIBMADM.ENV_SYS_INFO
query = "SELECT * FROM SYSIBMADM.ENV_SYS_INFO"
stmt = ibm_db.exec_immediate(conn, query)
# Fetch and return the entries
rows = []
row = ibm_db.fetch_tuple(stmt)
while row:
rows.append(row)
row = ibm_db.fetch_tuple(stmt)
# Close the connection
ibm_db.close(conn)
print("Database connection closed.")
return rows
else:
print("Failed to connect to the database.")
return None
except Exception as e:
print("An error occurred:", e)
return None