# Installing ibm_db and ibm_db_dbi module
We are assuming that you have Python already installed. In Linux you may need the python-dev package (you can install python-dev package through "$yum install python-devel" if yum doesn't work then you can also install it through "$apt-get install python-dev")
Note:The minimum python version supported by driver is python 2.7 and the latest version supported is python 3.9 except version 3.3 as it has reached end-of-life.
## Installation
```
pip install ibm_db
or
easy_install ibm_db
```
This will install *ibm_db* and *ibm_db_dbi* module.
If you face problems due to missing python header files, you would need to install python developer package before installing python ibm_db driver.
e.g:
```
zypper install python-devel
or
yum install python-devel
```
### Environment Variables
`IBM_DB_HOME :`
Set this environment variable to avoid automatic downloading of the clidriver during installation. You could set this to the installation path of ODBC and CLI driver in your environment. The list of supported platforms and installation file names are listed in the table under License requirements.
### IBM_DB and DB-API wrapper (ibm_db_dbi) sanity test
```python
$ python
Python 3.6.5 (default, May 10 2018, 00:54:55)
[GCC 4.3.4 [gcc-4_3-branch revision 152973]] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ibm_db
>>> #For connecting to local database named pydev for user db2inst1 and password secret, use below example
>>> #ibm_db_conn = ibm_db.connect('pydev', 'db2inst1', 'secret')
>>> #For connecting to remote database named pydev for uid db2inst and pwd secret on host host.test.com, use below example
>>> conn_str='database=pydev;hostname=host.test.com;port=portno;protocol=tcpip;uid=db2inst1;pwd=secret'
>>> ibm_db_conn = ibm_db.connect(conn_str,'','')
>>> import ibm_db_dbi
>>> conn = ibm_db_dbi.Connection(ibm_db_conn)
>>> conn.tables('SYSCAT', '%')
```
More examples can be found under 'ibm_db_tests' folder.
### License requirements for connecting to databases
Python ibm_db driver can connect to DB2 on Linux Unix and Windows without any additional license/s, however, connecting to databases on DB2 for z/OS or DB2 for i(AS400) Servers require either client side or server side license/s. The client side license would need to be copied under `license` folder of your `cidriver` installation directory and for activating server side license, you would need to purchase DB2 Connect Unlimited for System z® and DB2 Connect Unlimited Edition for System i®.
To know more about license and purchasing cost, please contact [IBM Customer Support](http://www-05.ibm.com/support/operations/zz/en/selectcountrylang.html).
To know more about server based licensing viz db2connectactivate, follow below links:
* [Activating the license certificate file for DB2 Connect Unlimited Edition](https://www.ibm.com/developerworks/community/blogs/96960515-2ea1-4391-8170-b0515d08e4da/entry/unlimited_licensing_in_non_java_drivers_using_db2connectactivate_utlility1?lang=en).
* [Unlimited licensing using db2connectactivate utility](https://www.ibm.com/developerworks/community/blogs/96960515-2ea1-4391-8170-b0515d08e4da/entry/unlimited_licensing_in_non_java_drivers_using_db2connectactivate_utlility1?lang=en.)
Following are the details of the client license versions that you need to be able to connect to databases on non-LUW servers:
#### <a name="LicenseDetails"></a> Client license for Specific Platform and Architecture
|Platform |Architecture |Cli Driver |Supported |Version |
| :---: | :---: | :---: | :---: | :--:
|AIX | ppc |aix32_odbc_cli.tar.gz | Yes | V11.1 |
| | others |aix64_odbc_cli.tar.gz | Yes | V11.1 |
|Darwin | x64 |macos64_odbc_cli.tar.gz | Yes | V11.1 |
|Linux | x64 |linuxx64_odbc_cli.tar.gz | Yes | V11.1 |
| | s390x |s390x64_odbc_cli.tar.gz | Yes | V11.1 |
| | s390 |s390_odbc_cli.tar.gz | Yes | V11.1 |
| | ppc64 (LE) |ppc64le_odbc_cli.tar.gz | Yes | V11.1 |
| | ppc64 |ppc64_odbc_cli.tar.gz | Yes | V10.5 |
| | ppc32 |ppc32_odbc_cli.tar.gz | Yes | V10.5 |
| | others |linuxia32_odbc_cli.tar.gz| Yes | V11.1 |
|Windows | x64 |ntx64_odbc_cli.zip | Yes | V11.1 |
| | x32 |nt32_odbc_cli.zip | Yes | V11.1 |
|Sun | i86pc |sunamd64_odbc_cli.tar.gz | Yes | V10.5 |
| | |sunamd32_odbc_cli.tar.gz | Yes | V10.5 |
| | sparc |sun64_odbc_cli.tar.gz | Yes | V11.1 |
| | sparc |sun32_odbc_cli.tar.gz | Yes | V11.1 |
### Issues with MAC OS X
* If you run into errors for libdb2.dylib as below:
```python
>>> import ibm_db
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dlopen(/usr/local/lib/python3.5/site-packages/ibm_db.cpython-35m-darwin.so, 2): Library not loaded: libdb2.dylib
Referenced from: /usr/local/lib/python3.5/site-packages/ibm_db.cpython-35m-darwin.so
Reason: image not found
```
You would need to set DYLD_LIBRARY_PATH to point to lib folder as per the installation location of clidriver in your environment. Assuming the driver is installed at /usr/local/lib/python3.5/site-packages/clidriver, you can set the path as:
```
export DYLD_LIBRARY_PATH=/usr/local/lib/python3.5/site-packages/clidriver/lib:$DYLD_LIBRARY_PATH
```
If the issue is not resolved even after setting DYLD_LIBRARY_PATH, you could refer:
[MAC OS Hints and Tips](https://www.ibm.com/developerworks/community/blogs/96960515-2ea1-4391-8170-b0515d08e4da/entry/ibm_db_on_MAC_OS_Hints_and_Tips?lang=en)
* Resolving SQL1042C error
If you hit following error while attempting to connect to a database:
```python
>>> import ibm_db
>>> ibm_db.connect("my_connection_string", "", "")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
Exception: [IBM][CLI Driver] SQL1042C An unexpected system error occurred. SQLSTATE=58004 SQLCODE=-1042
```
Set DYLD_LIBRARY_PATH to point to icc folder as per the installation location of clidriver in your environment.
```
export DYLD_LIBRARY_PATH=/usr/local/lib/python3.5/site-packages/clidriver/lib/icc:$DYLD_LIBRARY_PATH
```
### Supported databases
* **Minimum Supported version of IBM DB2 is V9fp2 for Linux, UNIX, and Windows**
* Informix 11.10 **(Cheetah)**
* Remote connections to i5/OS (iSeries)
* Remote connections to z/OS (DB2 for z/OS)
# Feedback
**Your feedback is very much appreciated and expected through project ibm-db:**
* ibm-db issues reports: **https://github.com/ibmdb/python-ibmdb/issues**
* ibm_db discuss: **http://groups.google.com/group/ibm_db**
# Testing
Tests displaying Python ibm_db driver code examples are located in the ibm_db_tests
directory. A valid config.py will need to be created to configure your DB2
settings. A config.py.sample exists that can be copied and modified for your
environment.
The config.py should look like this:
```python
test_dir = 'ibm_db_tests' # Location of testsuite file (relative to current directory)
database = 'test' # Database to connect to
user = 'db2inst1' # User ID to connect with
password = 'password' # Password for given User ID
hostname = 'localhost' # Hostname
port
没有合适的资源?快使用搜索试试~ 我知道了~
资源详情
资源评论
资源推荐
收起资源包目录
ibm_db-3.1.0-new.tar.gz (500个子文件)
libDB2xml4c.so.58.0 4.83MB
libdb2.so.1 35.24MB
IBMkrb5.so.1 71KB
libdb2clixml4c.so.1 30KB
libDB2xml4c.so.58 4.83MB
DigiCertGlobalRootCA.arm 1KB
conlic.bin 0B
db2clist.bnd 4KB
db2spcdb.bnd 3KB
db2cli.bnd 472B
db2ajgrt.bnd 469B
db2clipk.bnd 302B
ibm_db.c 432KB
1388ucs2.cnv 91KB
0954ucs2.cnv 80KB
09370950.cnv 57KB
ucs20943.cnv 54KB
0939ucs2.cnv 33KB
0930ucs2.cnv 33KB
0943ucs2.cnv 29KB
5039ucs2.cnv 23KB
12080923.cnv 6KB
09231208.cnv 928B
09230850.cnv 416B
04370923.cnv 416B
11140923.cnv 416B
09231252.cnv 416B
09231043.cnv 416B
09230437.cnv 416B
09231275.cnv 416B
10510923.cnv 416B
12520850.cnv 416B
12750923.cnv 416B
10430923.cnv 416B
08501252.cnv 416B
08500923.cnv 416B
09231114.cnv 416B
08600923.cnv 416B
09230860.cnv 416B
09241252.cnv 416B
09231051.cnv 416B
12520923.cnv 416B
08630923.cnv 416B
db2cli 1.02MB
db2diag 652KB
db2drdat 38KB
db2dsdcfgfill 166KB
db2ldcfg 30KB
db2lddrg 34KB
db2level 91KB
db2support 167KB
db2trc 1.44MB
ibm_db-3.1.0-py3.8-linux-x86_64.egg 561KB
.ftok 4B
linuxx64_odbc_cli.tar.gz 20.14MB
sqlenv.h 356KB
sql.h 181KB
sqlext.h 87KB
sqlcli1.h 76KB
sqlstate.h 70KB
sqlcli.h 33KB
ibm_db.h 15KB
sqlda.h 15KB
sqlsystm.h 4KB
sqlca.h 4KB
sqltypes.h 681B
sqlucode.h 681B
sqlunx.h 681B
MANIFEST.in 271B
LICENSE 9KB
db2clia1.lst 2KB
db2clias.lst 1KB
db2cli.lst 53B
CHANGES.md 15KB
README.md 10KB
NOTES.md 2KB
db2sqlh.mo 3.11MB
db2sql.mo 434KB
db2admh.mo 268KB
db2clp.mo 263KB
db2stt.mo 117KB
db2adm.mo 108KB
db2clih.mo 90KB
db2supp.mo 67KB
db2diag.mo 59KB
db2clp2.mo 18KB
db2cli.mo 17KB
db2fodc.mo 15KB
db2caem.mo 5KB
db2cklog.mo 3KB
db2clit.mo 2KB
ibm_db.o 711KB
odbc_LI_cs 37KB
odbc_LI_de 43KB
odbc_LI_el 80KB
odbc_LI_en 60KB
odbc_LI_es 40KB
odbc_LI_fr 51KB
odbc_LI_in 37KB
odbc_LI_it 37KB
共 500 条
- 1
- 2
- 3
- 4
- 5
devops+
- 粉丝: 4
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0