Skip to main content

Pool DB package

Project description

PoolDB

python数据库连接池管理,支持并发获取sql数据,自动管理数据库连接,支持with语句,支持sql字典访问形式获取数据等

  • 原生sql获取数据
db_url = 'postgresql+psycopg2://postgres:pgpasswd@172.16.1.64:5433/dw_jinan?utf-8'
pool = PoolDB(db_url=db_url)
conn = pool.connect()
result = conn.execute("select * from manage.substation limit 5")
while 1:
    try:
        r = next(result)
        print(r)
        print(r.pid)
    except:
        break
pool.close(conn)
  • 并发获取数据库数据
db_url = 'postgresql+psycopg2://postgres:pgpasswd@172.16.1.64:5433/dw_jinan?utf-8'
pool = PoolDB(db_url=db_url)
gv = pool.multi_data(sql=sqls)  # 多条数据并发获取,
for v in gv:
    print(v)
  • 字典形式访问获取数据库数据, key为sql或sql列表
db_url = 'postgresql+psycopg2://postgres:pgpasswd@172.16.1.64:5433/dw_jinan?utf-8'
pool = PoolDB(db_url=db_url)
r = pool["select * from manage.substation limit 5"]  
print(r)
sqls = ["select * from manage.substation limit 5", "select * from manage.substation limit 4"]
r_list = pool[sqls]  
print(r_list)

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

PoolDB-0.0.1-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file PoolDB-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: PoolDB-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/46.1.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.8

File hashes

Hashes for PoolDB-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 76d0d7929e2640cd204bf4be03273542ef62f18a36a4355bc1f247563f19875b
MD5 46af5585a3d24c927477e06fec4a776a
BLAKE2b-256 19c1d4481cc118e03c81784b7ba50023c4a9b2dd44c778d23d64d4ae0b4e7200

See more details on using hashes here.

Supported by

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