Linux (Centos) Python compile and install Dameng driver dmPython
原文链接 https://www.aiprose.com/blog/151 点击访问
dmPython is a database access interface developed by DM based on the API usage regulations in Python DB API version 2.0.
You need to install dmPython when using Python to connect to the Dameng database. After installing the DM database software, you can find the driver source code of dmPython in the drivers directory under the installation path. Since the source code is provided, you need to compile and install it yourself.
When installing, distinguish whether the machine has already installed the Dameng database. If the machine has already installed the Dameng database, refer to the first type. If the machine is not installed, please refer to the second one.
Linux platform installation method one
Note: DM database needs to be installed first
1.Download the driver package source code
wget https://download.dameng.com/eco/docs/python-126594-20201027.zip
or
curl https://download.dameng.com/eco/docs/python-126594-20201027.zip -o python-126594-20201027.zip
2.Unzip the driver package
unzip python-126594-20201027.zip
3.Compile the driver package
//cd your Driver source code decompression directory
cd python/dmPython_C/dmPython
python setup.py install
Linux platform installation method two
Note: There is no DM database installed on this machine
1.Download the driver package source code
wget https://download.dameng.com/eco/docs/python-126594-20201027.zip
or
curl https://download.dameng.com/eco/docs/python-126594-20201027.zip -o python-126594-20201027.zip
2.Unzip the driver package
unzip python-126594-20201027.zip
3.Install gcc
Compilation and installation must be GCC, if not installed, please install it first
yum install gcc
4.Set environment variables
Set the DM_HOME environment variable to a certain directory, assuming it is: /data/publish/python/dmdbms
Note: dmPython completes the Python module extension by calling the DM DPI interface. In its use, in addition to the Python standard library, a DPI operating environment is also required.
vi /etc/profile
// Add the following configuration
export DM_HOME=/data/publish/python/dmdbms
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/data/publish/python/dmdbms/
source /etc/profile
If LD_LIBRARY_PATH is not set, an error will be reported:
import dmPython
File "build/bdist.linux-x86_64/egg/dmPython.py", line 7, in <module>
File "build/bdist.linux-x86_64/egg/dmPython.py", line 6, in __bootstrap__
ImportError: libdmdpi.so: cannot open shared object file: No such file or directory
5.Copy files // Copy from other machines with the same operating system where DM database has been installed, or download my available files Click to download dpi file
Copy all files under dmserver/drivers/dpi to /data/publish/python/dmdbms
5.Compile the dmPython
//cd your Driver source code decompression directory
cd python/dmPython_C/dmPython
python setup.py install
If an error is reported, there is no such file or directory in Python.h
Solution: Install the python-devel dependency package.
yum install python-devel
//python3
yum install python3-devel
Then execute
python setup.py install
The successful compilation is as shown in the figure:
Compilation result
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
You can check whether the installation is successful through pip list
Write test code
vi testdm.py
#!/usr/bin/python
#coding:utf-8
import dmPython
try:
conn = dmPython.connect(user='SYSDBA', password='SYSDBA', server='192.168.0.122', port=5236)
cursor = conn.cursor()
print('python: conn success!')
conn.close()
except (dmPython.Error, Exception) as err:
print(err)
Then execute
python test.py
If the connection is successful, it will output conn success!
相关文章
- 【技术种草】cdn+轻量服务器+hugo=让博客“云原生”一下
- CLB运维&运营最佳实践 ---访问日志大洞察
- vnc方式登陆服务器
- 轻松学排序算法:眼睛直观感受几种常用排序算法
- 十二个经典的大数据项目
- 为什么使用 CDN 内容分发网络?
- 大数据——大数据默认端口号列表
- Weld 1.1.5.Final,JSR-299 的框架
- JavaFX 2012:彻底开源
- 提升as3程序性能的十大要点
- 通过凸面几何学进行独立于边际的在线多类学习
- 利用行动影响的规律性和部分已知的模型进行离线强化学习
- ModelLight:基于模型的交通信号控制的元强化学习
- 浅谈Visual Source Safe项目分支
- 基于先验知识的递归卡尔曼滤波的代理人联合状态和输入估计
- 结合网络结构和非线性恢复来提高声誉评估的性能
- 最佳实践丨云开发CloudBase多环境管理实践
- TimeVAE:用于生成多变量时间序列的变异自动编码器
- 具有线性阈值激活的神经网络:结构和算法
- 内网渗透之横向移动 -- 从域外向域内进行密码喷洒攻击