Skip to main content

dbcfg本身

dbcfg的python包。包含python的库以及dbcfg本身。

dbcfg项目地址

https://gitee.com/chenc224/dbcfg

安装

执行

pip install dbcfg

即可下载安装

使用方法

初始化

import dbcfg
db=dbcfg.use("xxx",ehm=1)

ehm参数表用于控制有问题、有异常时如何处理

ehm 处理细节
0 默认值,不特殊处理。
1 如果调用的返回码为非0,则打印rtinfo的内容
2 如果调用的返回码为非0,则触发异常

xxx是配置名称,详细内容参考dbcfg项目文档

初始化完成,后续可以通过db操作配置文件,并且可以直接使用db对数据库进行一些常见操作。

查询类

for a,b,c in db.q("select a,b,c from table where a>3 and d not null"):
	print(a,b,c)

q函数,用来循环处理多条数据,并不全部取入内存,所以可以处理很大的数据量。

for row in db.qt("select a,b,c from table where a>3 and d not null"):
	print(row["A"],row["B"],row["C"])

qt函数,类似q函数,只是返回的值字典,索引是字段名(注意大小写要正确)。

a,b=db.q1("select a,b from table where id=5")

q1函数,用于取回一行数据。

row=db.q1t("select a,b from table where id=5")

q1t函数,类似q1函数,只是返回的值是以字段名为索引的字典。

列表=db.qa("select a,b from table where a is not null")

qa函数,返回一个列表,包含所有的查询结果,自己注意内存要够用。

qat函数,类似qa函数,只是列表中包含的是字典。

列表=db.qn(100,"select a,b from table where a is not null")

qn函数,类似qa函数,返回不超过指定数量的结果。

qnt函数,类似qn函数,列表中包含的是字典。

Metadata

Release files for dbcfg 0.3.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dbcfg 0.3.5
File Size Uploaded Provenance Actions
dbcfg-0.3.5.tar.gz 10.6 kB Without provenance Details for dbcfg-0.3.5.tar.gz

Release files / dbcfg-0.3.5.tar.gz

Download URL dbcfg-0.3.5.tar.gz
Size 10.6 kB
Tags Source
SHA-256 checksum
How to use checksums
00ec9cca36c076af4dacff0a8759a2b7706112922d09b146a467ea58ed095b26
BLAKE2b-256 checksum
How to use checksums
de53552bb133915b4836962358156da88f2af605eb8a09ff6e43ba8a1acdd4da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Security for dbcfg 0.3.5

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page