club-seiden / -ibmi_netstat_py Goto Github PK
View Code? Open in Web Editor NEW[OLD VERSION] Python script for IBM i that provides NETSTAT information (see readme for current location)
License: MIT License
[OLD VERSION] Python script for IBM i that provides NETSTAT information (see readme for current location)
License: MIT License
Add try/except logic to catch a failed database connection.
With the latest version of the ibm_db Python adapter you can now omit the user/password and it will run under the profile that is invoking the script. Below is a sample script. Note the use of None
.
Btw, I just got this working on Litmis Spaces if anyone wants to take a swing at it and doesn't yet have the latest PTFs on their machine.
import ibm_db
db_name = '*LOCAL'
schema = '<insert Schema>'
username = None
password = None
try:
conn = ibm_db.connect(db_name, username, password)
except:
print("no connection:", ibm_db.conn_errormsg())
if conn:
result_set = ibm_db.exec_immediate(conn, "SET SCHEMA " + schema)
result_set = ibm_db.exec_immediate(conn, "CREATE TABLE CUSTOMER ( CUSNUM NUMERIC(6, 0), LSTNAM VARCHAR(50) )")
result_set = ibm_db.exec_immediate(conn, "INSERT INTO CUSTOMER VALUES(123,'Smith')")
result_set = ibm_db.exec_immediate(conn, "SELECT * FROM CUSTOMER")
ibm_db.fetch_row(result_set)
print(ibm_db.result(result_set, 0))
print(ibm_db.result(result_set, 1))
ibm_db.close(conn)
else:
print ('connection failed')
Instead of:
conn = ibm_db.connect('dbname', 'username', 'password', {})
set and pass in variables, which will make the example easier to understand and modify:
conn = ibm_db.connect(db_name, username, password, {})
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.