目录
1.环境描述
2.安装系统依赖包
3.修改root用户环境变量
4.安装
5. 测试
1.环境描述
本次环境依赖操作系统自带的python
[root@sec1 ~]# cat /etc/redhat-release CentOS Linux release 7.6.1810 (Core) [root@sec1 ~]# [root@sec1 ~]# |
在$DM_HOME/drivers 目录下有多种类型的驱动。找到python的
[root@sec1 ~]# [root@sec1 ~]#?cd /dm/dmdbms/dm8/drivers/ [root@sec1 drivers]# [root@sec1 drivers]# ls dci? dotNet? dpi? fldr? go? jdbc? logmnr? odbc? php_pdo? python [root@sec1 drivers]# |
2.安装系统依赖包
yum install python-devel gcc* -y |
如果安装这2个包会出现错误
3.修改root用户环境变量
??需要root用户把dmpython安装到python里面去,当然也可以安装一个python
[root@sec1 ~]# [root@sec1 ~]#?more .bash_profile # .bash_profile
# Get the aliases and functions if [ -f ~/.bashrc ]; then ? ? ? ? . ~/.bashrc fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
export PATH="/dm/dmdbms/dm8/bin:$PATH"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/dm/dmdbms/dm8/bin" export DM_HOME="/dm/dmdbms/dm8" [root@sec1 ~]# [root@sec1 ~]# |
4.安装
我们需要手工安装dmPython 包。进入dmPython目录后执行命令:
[root@sec1 ~]# [root@sec1 ~]#?cd /dm/dmdbms/dm8/drivers/python/dmPython/ [root@sec1 dmPython]# [root@sec1 dmPython]#?ls Buffer.c? Connection.c? dmPython.egg-info? Error.h? ? exObject.c?? README.txt??setup.py?? trc.c? var_pub.h? vDateTime.c? vlong.c? ? vString.c Buffer.h? Cursor.c? ? ? Environment.c? ? ? exBfile.c? py_Dameng.c? row.c? ? ?? strct.h? ? trc.h? vBfile.c?? vInterval.c? vNumber.c build? ?? dist? ? ? ? ? Error.c? ? ? ? ? ? exLob.c? ? py_Dameng.h? row.h? ? ?? tObject.c? var.c? vCursor.c? vLob.c? ? ?? vObject.c [root@sec1 dmPython]#
[root@sec1 dmPython]#?python setup.py? install running install running bdist_egg ........................... ........................... ............................ Processing dmPython-2.3-py2.7-linux-x86_64.egg Copying dmPython-2.3-py2.7-linux-x86_64.egg to /usr/lib64/python2.7/site-packages Adding dmPython 2.3 to easy-install.pth file
Installed /usr/lib64/python2.7/site-packages/dmPython-2.3-py2.7-linux-x86_64.egg Processing dependencies for dmPython==2.3 Finished processing dependencies for dmPython==2.3 [root@sec1 dmPython]# [root@sec1 dmPython]# |
5. 测试
[root@sec1 dmPython]# [root@sec1 dmPython]#?python Python 2.7.5 (default, Oct 30 2018, 23:45:53) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> >>>?import dmPython /usr/lib64/python2.7/site-packages/dmPython-2.3-py2.7-linux-x86_64.egg/dmPython.py:3: UserWarning: Module dmPython was already imported from /usr/lib64/python2.7/site-packages/dmPython-2.3-py2.7-linux-x86_64.egg/dmPython.pyc, but /dm/dmdbms/dm8/drivers/python/dmPython is being added to sys.path >>> >>> >>>?conn=dmPython.connect(user='SYSDBA',password='dameng123',server='192.168.56.101',port=5236) >>>?cursor=conn.cursor() >>>?cursor.execute("select 'https://www.cndba.cn' from dual") <__builtin__.DmdbCursor on <dmPython.Connection to SYSDBA@192.168.56.101:5236>> >>> >>>?rets=cursor.fetchall() >>>?rets [('https://www.cndba.cn',)] >>> >>>?cursor.close() >>>?conn.close() >>> exit Use exit() or Ctrl-D (i.e. EOF) to exit >>> exit() [root@sec1 dmPython]# ? |
达梦数据库 - 新一代大型通用关系型数据库 | 达梦云适配中心达梦数据库产品体验站,DM8在线试玩,达梦数据库全系列产品免费下载,官方权威的快速上手文档和产品手册,最活跃的达梦技术社区,面向全行业ISV厂商免费的云适配服务。https://eco.dameng.com/
|