达梦与Python之dmPython的安装
目录1.环境描述2.安装系统依赖包3.修改root用户环境变量4.安装5. 测试1.环境描述本次环境依赖操作系统自带的python[root@sec1 ~]# cat /etc/redhat-releaseCentOS Linux release 7.6.1810 (Core)[root@sec1 ~]#[root@sec1 ~]#在$DM_HOME/drivers 目录下有多种类型的驱动。找到p
目录
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.安装系统依赖包
|
如果没有安装这2个包会出现错误
3.修改root用户环境变量
dmpython需要root用户来安装,先修改环境编辑
[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 |
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]# |
更多推荐
所有评论(0)