otssql
一款满足 Python Database API Specification v2.0 规范的 tablestore 的 SQL 版连接器。实现了官方 SDK 的 SQL 查询功能不支持的
UPDATE 语句和 DELETE 语句功能。
安装方法
pip install otssql
使用方法
使用方法与满足 Python Database API Specification v2.0 规范的其他 SQL 连接器相同。
import otssql
import ssl
# 创建 otssql 的 Connection 对象
ots_conn = otssql.connect("", "", "", "", ssl_version=ssl.PROTOCOL_TLSv1_2)
# 构造 otssql 的 Cursor 对象
ots_cursor = ots_conn.cursor(otssql.DictCursor)
# 调用 otssql 的 Cursor 对象的 execute 方法执行 SQL 语句
cnt = ots_cursor.execute("SELECT column_1 FROM table_name WHERE column_2 = 1")
# 查看获取结果行数或影响行数
print(cnt)
# 查看获取结果的描述信息
print(ots_cursor.description)
# 查看查询结果的数据集
if ots_cursor.current_result is not None:
result = ots_cursor.fetchall()
for row in result:
print(row)
因为 tablestore SDK 原生不支持 SQL(不支持 UPDATE 和 DELETE 语句),而 otssql 本质上是一个连接器而非引擎,不进行计算,所以存在如下需要注意的局限:
- 在多次运行时,
Cursor返回的 tuple 结果中元素先后顺序不固定,建议使用DictCursor - 所有 SQL 语句的查询部分,仅 尝试使用多元索引实现,如没有多元索引会触发报错
- 不支持部分 SQL 语句(可尝试执行 SQL,如不支持会抛出
NotSupportError)
如果你希望在 OTS 中执行复杂的 SQL 语句或希望执行不包含多元索引的查询,建议直接使用 tablestore SDK。
Metadata
Release files for otssql 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| otssql-0.1.0.tar.gz | 26.7 kB | Without provenance | Details for otssql-0.1.0.tar.gz |
Release files / otssql-0.1.0.tar.gz
| Download URL | otssql-0.1.0.tar.gz |
|---|---|
| Size | 26.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3c39ba0c4597d42566e415b06a25ec88bcf9aeb59fec78388d68c87bfccf2f11
|
|
BLAKE2b-256 checksum How to use checksums |
b3ed7c533a5e088ffb04b1443daf9e2ec2f4c515aea5830df4e5d0f49608f374
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.9.6 readme-renderer/42.0 requests/2.31.0 requests-toolbelt/1.0.0 urllib3/1.26.0 tqdm/4.66.1 importlib-metadata/7.0.1 keyring/24.3.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.10.6
|
Security for otssql 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.