Skip to main content

A simple package for db connection.

Project description

BRTG database connector

Simple package to establish connection with mysql/mariadb database using sqlalchemy.

Prerequisite

Environmental variables:

DB_HOST=host.com DB_PORT=3306 DB_USER=your_user DB_PASS=your_password

Installation

From package directory:

pip install brtgdb

Usage

###Import Pristupove udaje su v subore .env

from dotenv import load_dotenv
load_dotenv()

Vytovirm konektor

from brtgdb import BrtgDB

db = BrtgDB()

Read SQL With pandas

pd.read_sql("SELECT ....", db.conn)

Execute SQL command

db.execute(query)

Add table connector and usage

table = db.add_table_connector(table_name, schema_name=None)
stmt = insert(table).values(column1= value1 , column2= value2)
db.conn.execute(stmt) 

Logging db changes

db.log_change(job_name='update_data_analysis',
              table_name='ruz_t_data_analysis',
              event_type='INSERT AND UPDATE',  # ERROR
              details=json.dumps(result))

Logging test results

db.log_test_results(test_run=validation_result["run_id"].run_name,
                    status=validation_result["success"],
                    details='See great_expectations report.')

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

brtgdb-0.3.6.tar.gz (2.7 kB view details)

Uploaded Source

Built Distribution

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

brtgdb-0.3.6-py3-none-any.whl (2.8 kB view details)

Uploaded Python 3

File details

Details for the file brtgdb-0.3.6.tar.gz.

File metadata

  • Download URL: brtgdb-0.3.6.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.8.5

File hashes

Hashes for brtgdb-0.3.6.tar.gz
Algorithm Hash digest
SHA256 35ff598618de9bc6b37c87ad490ca8fc3d3e8d60eec297e179a5e107db7f2568
MD5 9e17bb4de588677a92fc0d28cbd8bf03
BLAKE2b-256 15baa94ce72e37ac522b22b22abb1a0148c23e922bb23a52112f6c0207bb1f70

See more details on using hashes here.

File details

Details for the file brtgdb-0.3.6-py3-none-any.whl.

File metadata

  • Download URL: brtgdb-0.3.6-py3-none-any.whl
  • Upload date:
  • Size: 2.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.8.5

File hashes

Hashes for brtgdb-0.3.6-py3-none-any.whl
Algorithm Hash digest
SHA256 ddaa6daebdeda582ac79eb48e2a15841bf1ee3f18a9b5e0c740eda70ab340e79
MD5 1eb3614aea6d7fa51da02b8e057aa8b2
BLAKE2b-256 20a9c7aa689b42dab89b49481dee049b499a0da7c89a27e20486e56e8d9f0d99

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