问题背景
- 有客户提出来他们的客户端是Python的,需要使用Python语言查询Doris。
问题解决思路
- Doris高度兼容MySQL协议,Java客户端目前使用MySQL JDBC Client查询Doris。
- Python也有MySQL Client,因此建议使用PHP MySQL Client,下面进行实战。
代码实战
1. python环境安装
我服务默认为Python2.7 ,下面介绍下在2.7环境上PyMySQL的安装。
-
pip安装:python get-pip.py
[root@17a5da45700b python]# python --version Python 2.7.5 #download pip curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py #install pip sudo python get-pip.py -
PyMySQL安装
[root@17a5da45700b python]# pip install PyMySQL
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Collecting PyMySQL
Downloading PyMySQL-0.10.1-py2.py3-none-any.whl (47 kB)
|################################| 47 kB 9.3 MB/s
Installing collected packages: PyMySQL
Successfully installed PyMySQL-0.10.1
-
安装结果验证:pip list |grep PyMySQL
[root@17a5da45700b python]# pip list |grep PyMySQL DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality. PyMySQL 0.10.1
2. 功能测试
-
创建Doirs用户。
create

客户提出用Python语言查询Doris的需求。因Doris高度兼容MySQL协议,Python有MySQL Client,故建议使用。博客介绍了在Python2.7环境上安装PyMySQL,还进行了功能测试,包括创建用户、表,插入数据,编写查询代码等。
最低0.47元/天 解锁文章
4624





