Skip to main content

help access SQL

Project description

db_utils library

Installation

pip install db_utils

pg_connect class (previously DBUtil)

A database connection class to interact with Postgres or Redshift

Basic Usage:

  • create database configuration file
  • example below is called .databases.conf
    [redshift_example]
    host=redshift.example.com
    user=test_user
    password=password
    port=5439
    database=test_db

    >>> from db_utils.pg_connect import pg_connect
    >>>
    >>> db = pg_connect('redshift_example', '.databases.conf')
    >>> db.get_arr_from_query('select * from test', pprint=True)

snowflake_connect class

A database connection class to interact with snowflake

Basic Usage:

  • create database configuration file
  • example below is called .databases.conf
    [snowflake]
    account=abc123.us-east-1
    host=abc123.us-east-1.snowflakecomputing.com
    user=test_user
    password=password
    port=443
    database=test_db

db_connect class

Parent python database connectin class utilizing API specification v2.0 https://www.python.org/dev/peps/pep-0249/#connection-methods use the connection classes above specific to the flavor of db you're using

s3_connect class

Connection library for interacting with S3

Basic Usage:

  • add s3 section to .databases.conf file (created in previous example)
    [s3]
        aws_access_key_id=<key_id>
        aws_secret_access_key=<secret_key>
        default_bucket=<bucket>


    >>> from db_utils.s3_connect import s3_connect
    >>>
    >>> s3 = s3_connect('.databases.conf', 's3')
    >>> s3.list_keys(prefix='examples')

dynamodb_connect class

Connection library for interacting with Dynamodb

timer class

Helper class to time long running processes

Basic Usage:

>>> from db_utils.timer import timer
>>>
>>> t = timer()
>>> t.lap('s')
5.469961

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

db_utils-0.2.2.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

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

db_utils-0.2.2-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

Details for the file db_utils-0.2.2.tar.gz.

File metadata

  • Download URL: db_utils-0.2.2.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.5.2

File hashes

Hashes for db_utils-0.2.2.tar.gz
Algorithm Hash digest
SHA256 6e694d5d31d4f50651e21dff9fd67d84093f46c09845d7a851a5b3e096296b72
MD5 cb92b5a1f00cb8fb6dde7678818047cf
BLAKE2b-256 da7730c8f3fce7de5aa8e588695f9be7360e7803a763c2706c4f8f70b71e0487

See more details on using hashes here.

File details

Details for the file db_utils-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: db_utils-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 15.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.5.2

File hashes

Hashes for db_utils-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 510cd62f7f918659a139b94565c5333956314e40fb79c1ccfc34ec70d3a8ade8
MD5 4adfbfb87a3b9de99809a236d41721cd
BLAKE2b-256 55fbb4d24d2493878d8395ec87f4efbd092919e0a177f210592c0220ece426b4

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