Skip to main content

utility tools for db access and data extraction

Project description

db-toolkit

from db_toolkit.db_extract import *
from db_toolkit.db_connect import *
from pathlib import Path

This file will become your README and also the index of your documentation.

Developer Guide

If you are new to using nbdev here are some useful pointers to get you started.

Install db_toolkit in Development mode

# make sure db_toolkit package is installed in development mode
$ pip install -e .

# make changes under nbs/ directory
# ...

# compile to have changes apply to db_toolkit
$ nbdev_prepare

Usage

Installation

To use this package in another project, install as below

Install latest from the AzureDevOps repository:

$ pip install git+https://lambeth@dev.azure.com/lambeth/Analytics/_git/db-toolkit

Dependencies

The YAML file for this package dependencies can be found in the envs\ DIR. If using toolkit on another project, it is advisable to define db-toolkit as the below format YAML.

name: er
channels:
  - conda-forge
dependencies:
  - jupyterlab
  - pandas
  - oracledb
  - pyodbc
  - pip
  - pip:
    - nbdev
    - git+https://lambeth@dev.azure.com/lambeth/Analytics/_git/db-toolkit
    - sqlalchemy

Documentation

TODO potentially when github is available.

How to use

Set ini file location path

  • TODO init file struct details show example
fpath2 = '../../../data/db_connections/cfg_address.ini'
dbe = DBExtract(cfg_fpath=fpath2)

SQL files

  • Saved at ../data/sql
  • TODO add details on path <dbname>__<tablename>

source

DBConfig

DBConfig (file_path)

Constructor for the DBConfig class. Reads parameters from the specified configuration file and presents them appropriately to the application.


source

DBExtract

DBExtract (cfg_fpath)

Constructor for the DBExtract class. Reads parameters from the specified configuration file Pairs SQL scrit to connection engine Pulls and saves data to landing folder

data_dir = Path("../data")
sql_dir = data_dir / 'sql'
sql_files = list(sql_dir.glob("*.sql"))
sql_files
[Path('../data/sql/BIODS__address_ctax.sql')]

Process files

# files wil be saved at ../data/landing
# dbe.process_save_landing()

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.

db_toolkit-0.0.1-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: db_toolkit-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for db_toolkit-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4eab3cd821a9ebe6210383b368a12c52af3124783aeee5fcad2b1b1963f50b2e
MD5 082f696c17caeeea1312867365c1347f
BLAKE2b-256 e473d3ff66bb8967657632d2fc77190c245789deba8b5649d8ee20ba470e6ef7

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