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函数,列表中包含的是字典。
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file dbcfg-0.3.5.tar.gz.
File metadata
- Download URL: dbcfg-0.3.5.tar.gz
- Upload date:
- Size: 10.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/4.0.2 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00ec9cca36c076af4dacff0a8759a2b7706112922d09b146a467ea58ed095b26
|
|
| MD5 |
d22abc90eee52f1671266ef100fa4a3d
|
|
| BLAKE2b-256 |
de53552bb133915b4836962358156da88f2af605eb8a09ff6e43ba8a1acdd4da
|