All Projects → KehaoWu → pgdb

KehaoWu / pgdb

Licence: other
psycopg2(Python中PostgreSQL连接器)的包装版,主要目的是解决psycopg2返回的是元组,这里根据列名将每一个数据变成字典和列表,方便进行操作。

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to pgdb

little pger
🐘 PostgreSQL query building with plain data structures.
Stars: ✭ 49 (+188.24%)
Mutual labels:  psycopg2
chm-documentation
chm documentation PostgreSQL pgadmin3 SQLAlchemy Django Flask jinja2 webpy doc chm compiled html help Postgres Postgre документация russian
Stars: ✭ 17 (+0%)
Mutual labels:  psycopg2

PostgreSQL 包装

安装

sudo pip install pgdb
# sudo python3 -m pip install pgdb

使用方法

from pgdb import Connection

## 链接PostgreSQL
connection = Connection(user='postgres', database='main', host='localhost')

## 执行普通查询,查询结果会根据字段名进行包装编程字典,不再是元组
connection.query("select * from main")

## 执行单条查询,结果与query类似
connection.get("select * from main limit 1")

## 执行普通操作
connection.execute("update main set status = 0")

## 执行普通多条操作
connection.executemany("insert into main values %(status)s", [{'status': 1}])

# 其他操作

cursor = connection.cursor()
connection.commit()
connection.rollback()
connection.close()

欢迎大家前来贡献代码

For development

python setup.py sdist

## edit ~/.pypirc
### [pypi]
### repository = https://pypi.python.org/pypi
### username =  
### password =  

twine register dist/pgdb-0.0.1.tar.gz
twine upload dist/pgdb-0.0.1.tar.gz
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].