Skip to main content

No project description provided

Project description

dbinterface

Build Status Coverage Status

Python 连接数据库,执行读写操作的通用接口。

安装

pip install dbinterface

使用方法

from dbinterface.database_client import DataBaseClientFactory

client1 = DataBaseClientFactory.create(
            dbtype="postgres",
            host="localhost",
            port=5432,
            user="postgres",
            pwd="121113",
            database="postgres",
        )
result1 = client1.read("select current_date")

client = DataBaseClientFactory.create(
            dbtype="mysql",
            host="localhost",
            port=3306,
            user="aaron",
            pwd="aaron",
            database="information_schema",
        )
result2 = client.read("select current_date()")

扩展

以 oracle 为例,在 dbinterface 目录下,新增 oracle_client.py 文件,参考其他 client 编写即可。

然后修改 dbinterface 目录下 database_client.py 文件,修改 DataBaseClientFactory 类,添加对应的数据库类型。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dbinterface-0.2.tar.gz (9.3 kB view hashes)

Uploaded Source

Built Distribution

dbinterface-0.2-py3-none-any.whl (17.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page