Python 构建和运行示例
SmartEDB安装软件包包含许多展示各个功能的 Python 示例。这些示例通过在各个示例目录中启动批处理命令(Windows)或 shell(Unix-Linux)文件在 Python 解释器中运行。
要开始使用前,请正确设定 PYTHONPATH 环境变量来启动 Python 解释器。默认情况下,Python 包装器将安装在 SmartEDB SDK 目录 target/bin/python 中。
Unix-Linux 构建过程
在 Unix-Linux 软件包中,通过调用相应的 shell 脚本在解释器中运行 Python 示例。例如,要从 samples/python/open 目录启动示例:
export PYTHONPATH=../../../target/bin/python
export PYTHONBIN=/opt/python32/python make target PYTHON=on
./Open.shWindows 构建过程
在 Windows 软件包中,通过调用相应的批处理脚本在解释器中运行 Python 示例。首先使用 Windows 系统对话框或控制台中的 setenv 命令设置 PYTHONPATH 和 PYTHONBIN 环境变量。例如:
setenv PYTHONPATH=..\..\..\target\bin\python
setenv PYTHONBIN=\opt\python32\python make target PYTHON=on在环境变量正确设置的情况下,通过简单地调用相应的批处理文件,就可以在解释器中运行 Python 示例。例如,要从 samples\python\open 目录启动 Open 示例:
Open.bat运行SDK示例
请使用下表中的链接查看每组中各个示例的运行说明。
| 所有安装包 | |
|---|---|
| core | Basic Python sample applications |
| sequences | Samples demonstrating use of the sequence data type |
| 含SQL组件 | |
| sql | Python SQL sample applications |
| 含高可用性组件 | |
| cluster | Python Cluster sample applications |
