Metadata-Version: 2.1
Name: dbcfg
Version: 0.3.5
Summary: 数据库连接信息管理
Author: Chen chuan
Author-email: kcchen@139.com
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE

# 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函数，列表中包含的是字典。

