Metadata-Version: 2.4
Name: db-toolkit
Version: 0.0.5
Summary: utility tools for db access and data extraction
Author-email: frangs <giordanofrancisco@duck.com>
License: Apache-2.0
Project-URL: Repository, https://github.com/Analytics/db-toolkit
Project-URL: Documentation, https://Analytics.github.io/db-toolkit
Keywords: nbdev,jupyter,notebook,python
Classifier: Natural Language :: English
Classifier: Intended Audience :: Developers
Classifier: Development Status :: 3 - Alpha
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: fastcore
Requires-Dist: pandas
Requires-Dist: sqlalchemy
Dynamic: license-file

# db-toolkit


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

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

## Developer Guide

### Install db_toolkit in Development mode

``` sh
# 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\]\[repo\]:

``` sh
$ pip install db-toolkit
```

## How to use

### 1. Set up your config file

Create an `.ini` file with your database connection details:

``` ini
[CONN_ORC]
user:TEST_USER
pass:<your_password>
dsn:<...>
port:<...>
dbname:<...>

[CONN_MS]
server:<...>
dbname:<...>
```

### 2. Create your SQL file

Save your query in `data/sql/` with the naming convention
`<CONNECTION>__<tablename>.sql`:

    data/sql/ODS__address_ctax.sql

### 3. Pull the data

``` python
from db_toolkit.db_extract import DBExtract

dbe = DBExtract(cfg_fpath='path/to/your/config.ini')
dbe.pull_table('BIODS__address_ctax')
```

The resulting CSV will be saved to `data/landing/`.
