Metadata-Version: 2.1
Name: qbo-db-connector
Version: 1.0.1
Summary: Connects Quickbooks to a database connector to transfer information to and fro.
Home-page: https://github.com/fylein/fyle-quickbooks-connector
Author: Shwetabh Kumar
Author-email: shwetabh.kumar@fyle.in
License: MIT
Keywords: fyle,quickbooks,db,python,sdk,sqlite,postgres
Platform: UNKNOWN
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Description-Content-Type: text/markdown
Requires-Dist: typing (==3.7.4.1)
Requires-Dist: pandas (==0.25.2)
Requires-Dist: logger (==1.4)
Requires-Dist: requests

# Quickbooks Online Database Connector
Connects Quickbooks online to a database to transfer information to and fro.

## Installation

This project requires [Python 3+](https://www.python.org/downloads/).

1. Download this project and use it (copy it in your project, etc).
2. Install it from [pip](https://pypi.org).

        $ pip install qbo-db-connector

## Usage

To use this connector you'll need these Quickbooks credentials used for OAuth2 authentication: **client ID**, **client secret** and **refresh token**.

This connector is very easy to use.
```python
import logging
import sqlite3
from qbosdk import QuickbooksOnlineSDK

from qbo_db_connector import QuickbooksExtractConnector, QuickbooksLoadConnector


dbconn = sqlite3.connect('/tmp/temp.db')

logger = logging.getLogger('Quickbooks usage')
logging.basicConfig(
    format='%(asctime)s %(name)s: %(message)s', level=logging.INFO, handlers=[logging.StreamHandler()]
)

quickbooks_config = {
    'client_id': '<CLIENT ID>',
    'client_secret': '<CLIENT SECRET>',
    'realm_id': '<REALM ID>',
    'refresh_token': '<REFRESH TOKEN>',
    'environment': '<ENVIRONMENT>',
}

logger.info('Quickbooks db connector usage')

connection = QuickbooksOnlineSDK(
    client_id=quickbooks_config['client_id'],
    client_secret=quickbooks_config['client_secret'],
    refresh_token=quickbooks_config['refresh_token'],
    realm_id=quickbooks_config['realm_id'],
    environment=quickbooks_config['environment']
)

quickbooks_extract = QuickbooksExtractConnector(qbo_connection=connection, dbconn=dbconn)
quickbooks_load = QuickbooksLoadConnector(qbo_connection=connection, dbconn=dbconn)

# make sure you save the updated refresh token
refresh_token = connection.refresh_token

# extracting
quickbooks_extract.extract_employees()
quickbooks_extract.extract_accounts()
quickbooks_extract.extract_classes()
quickbooks_extract.extract_departments()
quickbooks_extract.extract_home_currency()
quickbooks_extract.extract_exchange_rates()

# loading
quickbooks_load.load_check(check_id='100')
quickbooks_load.load_journal_entry(journal_entry_id='800')
quickbooks_load.load_attachments(ref_id='100', ref_type='Purchase')
```

## Contribute

To contribute to this project follow the steps

* Fork and clone the repository.
* Run `pip install -r requirements.txt`
* Setup pylint precommit hook
    * Create a file `.git/hooks/pre-commit`
    * Copy and paste the following lines in the file - 
        ```bash
        #!/usr/bin/env bash 
        git-pylint-commit-hook
        ```
     * Run `chmod +x .git/hooks/pre-commit`
## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details


