Skip to content

Commit

Permalink
Added Python Samples
Browse files Browse the repository at this point in the history
  • Loading branch information
dapper-hacker committed Oct 8, 2019
1 parent 6b40e9f commit 0757327
Show file tree
Hide file tree
Showing 193 changed files with 730,865 additions and 0 deletions.
13,347 changes: 13,347 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-active.html

Large diffs are not rendered by default.

13,433 changes: 13,433 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-autocommit.html

Large diffs are not rendered by default.

13,499 changes: 13,499 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-bind_param.html

Large diffs are not rendered by default.

13,412 changes: 13,412 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-callproc.html

Large diffs are not rendered by default.

13,396 changes: 13,396 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-client_info.html

Large diffs are not rendered by default.

13,364 changes: 13,364 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-close.html

Large diffs are not rendered by default.

13,465 changes: 13,465 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-column_privileges.html

Large diffs are not rendered by default.

13,525 changes: 13,525 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-columns.html

Large diffs are not rendered by default.

13,434 changes: 13,434 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-commit.html

Large diffs are not rendered by default.

13,396 changes: 13,396 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-conn_error.html

Large diffs are not rendered by default.

13,396 changes: 13,396 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-conn_errormsg.html

Large diffs are not rendered by default.

13,571 changes: 13,571 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-connect.html

Large diffs are not rendered by default.

13,510 changes: 13,510 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-createdb.html

Large diffs are not rendered by default.

13,510 changes: 13,510 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-createdbNX.html

Large diffs are not rendered by default.

13,462 changes: 13,462 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-cursor_type.html

Large diffs are not rendered by default.

13,509 changes: 13,509 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-dropdb.html

Large diffs are not rendered by default.

13,406 changes: 13,406 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-exec_immediate.html

Large diffs are not rendered by default.

13,420 changes: 13,420 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-execute.html

Large diffs are not rendered by default.

13,411 changes: 13,411 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-execute_many.html

Large diffs are not rendered by default.

13,411 changes: 13,411 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-fetch_assoc.html

Large diffs are not rendered by default.

13,412 changes: 13,412 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-fetch_both.html

Large diffs are not rendered by default.

13,406 changes: 13,406 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-fetch_row.html

Large diffs are not rendered by default.

13,411 changes: 13,411 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-fetch_tuple.html

Large diffs are not rendered by default.

13,423 changes: 13,423 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-field_display_size.html

Large diffs are not rendered by default.

13,419 changes: 13,419 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-field_name.html

Large diffs are not rendered by default.

13,380 changes: 13,380 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-field_num.html

Large diffs are not rendered by default.

13,412 changes: 13,412 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-field_precision.html

Large diffs are not rendered by default.

13,411 changes: 13,411 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-field_scale.html

Large diffs are not rendered by default.

13,422 changes: 13,422 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-field_type.html

Large diffs are not rendered by default.

13,411 changes: 13,411 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-field_width.html

Large diffs are not rendered by default.

13,507 changes: 13,507 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-foreign_keys.html

Large diffs are not rendered by default.

13,475 changes: 13,475 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-free_result.html

Large diffs are not rendered by default.

13,620 changes: 13,620 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-get_option.html

Large diffs are not rendered by default.

13,535 changes: 13,535 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-next_result.html

Large diffs are not rendered by default.

13,384 changes: 13,384 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-num_fields.html

Large diffs are not rendered by default.

13,443 changes: 13,443 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-num_rows.html

Large diffs are not rendered by default.

13,745 changes: 13,745 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-pconnect.html

Large diffs are not rendered by default.

13,426 changes: 13,426 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-prepare.html

Large diffs are not rendered by default.

13,417 changes: 13,417 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-primary_keys.html

Large diffs are not rendered by default.

13,542 changes: 13,542 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-procedure_columns.html

Large diffs are not rendered by default.

13,438 changes: 13,438 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-procedures.html

Large diffs are not rendered by default.

13,512 changes: 13,512 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-recreatedb.html

Large diffs are not rendered by default.

13,385 changes: 13,385 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-result.html

Large diffs are not rendered by default.

13,434 changes: 13,434 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-rollback.html

Large diffs are not rendered by default.

13,563 changes: 13,563 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-server_info.html

Large diffs are not rendered by default.

13,732 changes: 13,732 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-set_option.html

Large diffs are not rendered by default.

13,462 changes: 13,462 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-special_columns.html

Large diffs are not rendered by default.

13,513 changes: 13,513 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-statistics.html

Large diffs are not rendered by default.

13,388 changes: 13,388 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-stmt_error.html

Large diffs are not rendered by default.

13,389 changes: 13,389 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-stmt_errormsg.html

Large diffs are not rendered by default.

13,484 changes: 13,484 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-table_privileges.html

Large diffs are not rendered by default.

13,434 changes: 13,434 additions & 0 deletions python_samples/HTML_Documentation/ibm_db-tables.html

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions python_samples/HTML_Documentation/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This directory contains HTML files that document how to use the APIs found in the <b>ibm_db</b> library.
258 changes: 258 additions & 0 deletions python_samples/Jupyter_Notebooks/ibm_db-active.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,258 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"deletable": false,
"editable": false
},
"source": [
"# ibm_db.active()"
]
},
{
"cell_type": "markdown",
"metadata": {
"deletable": false,
"editable": false
},
"source": [
"## Purpose:"
]
},
{
"cell_type": "markdown",
"metadata": {
"deletable": false,
"editable": false
},
"source": [
"Determine whether the Db2 server or database connection specified is active."
]
},
{
"cell_type": "markdown",
"metadata": {
"deletable": false,
"editable": false
},
"source": [
"## Syntax:"
]
},
{
"cell_type": "markdown",
"metadata": {
"deletable": false,
"editable": false
},
"source": [
"`bool ibm_db.active( IBM_DBConnection `*`connection`*` )`"
]
},
{
"cell_type": "markdown",
"metadata": {
"deletable": false,
"editable": false
},
"source": [
"## Parameters:"
]
},
{
"cell_type": "markdown",
"metadata": {
"deletable": false,
"editable": false
},
"source": [
"* __*connection*__&nbsp; &nbsp; : A valid Db2 server or database connection."
]
},
{
"cell_type": "markdown",
"metadata": {
"deletable": false,
"editable": false
},
"source": [
"## Return values:"
]
},
{
"cell_type": "markdown",
"metadata": {
"deletable": false,
"editable": false
},
"source": [
"* `True` &nbsp; &nbsp; &nbsp;: The Db2 server or database connection specified is active. \n",
"* `False` &nbsp; &nbsp;: The Db2 server or database connection specified is not active."
]
},
{
"cell_type": "markdown",
"metadata": {
"deletable": false,
"editable": false
},
"source": [
"## Description:"
]
},
{
"cell_type": "markdown",
"metadata": {
"deletable": false,
"editable": false
},
"source": [
"The __ibm_db.active()__ API is used to determine if a Db2 server or database connection that was established using the __ibm_db.connect()__ API or __ibm_db.pconnect()__ is active.<p>"
]
},
{
"cell_type": "markdown",
"metadata": {
"deletable": false,
"editable": false
},
"source": [
"## Example:\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"deletable": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Connecting to the SAMPLE database ... Done!\n",
"\n",
"The connection to the SAMPLE database is ACTIVE.\n",
"\n",
"Disconnecting from the SAMPLE database ... Done!\n",
"\n"
]
}
],
"source": [
"#----------------------------------------------------------------------------------------------#\n",
"# NAME: ibm_db-active.py #\n",
"# #\n",
"# PURPOSE: This program is designed to illustrate how to use the ibm_db.active() API. #\n",
"# #\n",
"#----------------------------------------------------------------------------------------------#\n",
"# DISCLAIMER OF WARRANTIES AND LIMITATION OF LIABILITY #\n",
"# #\n",
"# (C) COPYRIGHT International Business Machines Corp. 2018, 2019 All Rights Reserved #\n",
"# Licensed Materials - Property of IBM #\n",
"# #\n",
"# US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA #\n",
"# ADP Schedule Contract with IBM Corp. #\n",
"# #\n",
"# The following source code (\"Sample\") is owned by International Business Machines #\n",
"# Corporation (\"IBM\") or one of its subsidiaries and is copyrighted and licensed, not sold. #\n",
"# You may use, copy, modify, and distribute the Sample in any form without payment to IBM, #\n",
"# for the purpose of assisting you in the creation of Python applications using the ibm_db #\n",
"# library. #\n",
"# #\n",
"# The Sample code is provided to you on an \"AS IS\" basis, without warranty of any kind. IBM #\n",
"# HEREBY EXPRESSLY DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT #\n",
"# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. #\n",
"# Some jurisdictions do not allow for the exclusion or limitation of implied warranties, so #\n",
"# the above limitations or exclusions may not apply to you. IBM shall not be liable for any #\n",
"# damages you suffer as a result of using, copying, modifying or distributing the Sample, #\n",
"# even if IBM has been advised of the possibility of such damages. #\n",
"#----------------------------------------------------------------------------------------------#\n",
"\n",
"# Load The Appropriate Python Modules\n",
"import sys # Provides Information About Python Interpreter Constants And Functions\n",
"import ibm_db # Contains The APIs Needed To Work With Db2 Databases\n",
"\n",
"#----------------------------------------------------------------------------------------------#\n",
"# Import The Db2ConnectionMgr Class Definition, Attributes, And Methods That Have Been Defined #\n",
"# In The File Named \"ibm_db_tools.py\"; This Class Contains The Programming Logic Needed To #\n",
"# Establish And Terminate A Connection To A Db2 Server Or Database #\n",
"#----------------------------------------------------------------------------------------------#\n",
"from ibm_db_tools import Db2ConnectionMgr\n",
"\n",
"#----------------------------------------------------------------------------------------------#\n",
"# Import The ipynb_exit Class Definition, Attributes, And Methods That Have Been Defined In #\n",
"# The File Named \"ipynb_exit.py\"; This Class Contains The Programming Logic Needed To Allow #\n",
"# \"exit()\" Functionality To Work Without Raising An Error Or Stopping The Kernel If The #\n",
"# Application Is Invoked In A Jupyter Notebook #\n",
"#----------------------------------------------------------------------------------------------#\n",
"from ipynb_exit import exit\n",
"\n",
"# Define And Initialize The Appropriate Variables\n",
"dbName = \"SAMPLE\"\n",
"userID = \"db2inst1\"\n",
"passWord = \"Passw0rd\"\n",
"dbConnection = None\n",
"\n",
"# Create An Instance Of The Db2ConnectionMgr Class And Use It To Connect To A Db2 Database\n",
"conn = Db2ConnectionMgr('DB', dbName, '', '', userID, passWord)\n",
"conn.openConnection()\n",
"if conn.returnCode is True:\n",
" dbConnection = conn.connectionID\n",
"else:\n",
" conn.closeConnection()\n",
" exit(-1)\n",
"\n",
"# Determine Whether The Current Database Connection Is Active Or Inactive\n",
"try:\n",
" connState = ibm_db.active(dbConnection)\n",
"except Exception:\n",
" pass\n",
"\n",
"# Display A Status Message That Shows The Current Connection State\n",
"print(\"The connection to the \" + dbName + \" database is \", end=\"\")\n",
"if connState is True:\n",
" print(\"ACTIVE.\\n\")\n",
"elif connState is False:\n",
" print(\"NOT ACTIVE.\\n\")\n",
"\n",
"# Close The Database Connection That Was Opened Earlier\n",
"conn.closeConnection()\n",
"\n",
"# Return Control To The Operating System\n",
"exit()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.1"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading

0 comments on commit 0757327

Please sign in to comment.