Skip to main content

Connects Quickbooks to a database connector to transfer information to and fro.

Project description

Quickbooks Online Database Connector

Connects Quickbooks online to a database to transfer information to and fro.


This project requires Python 3+.

  1. Download this project and use it (copy it in your project, etc).

  2. Install it from pip.

     $ pip install qbo-db-connector


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.

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')
    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>',
}'Quickbooks db connector usage')

connection = QuickbooksOnlineSDK(

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

# loading
quickbooks_load.load_attachments(ref_id='100', ref_type='Purchase')


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 -
      #!/usr/bin/env bash 
    • Run chmod +x .git/hooks/pre-commit
  • Make necessary changes
  • Run unit tests to ensure everything is fine

Unit Tests

To run unit tests, run pytest in the following manner:

python -m pytest test/unit

You should see something like this:

================================================================== test session starts ==================================================================
-------------------------------------------------------------------------------------------------------------------------------- live log call ---------------------------------------------------------------------------------------------------------------------------------
2019-12-24 12:10:46 [    INFO] test.unit.test_mocks: Testing mock data (
PASSED                                                                                                                                                                                                                                                                   [ 69%]
-------------------------------------------------------------------------------------------------------------------------------- live log call ---------------------------------------------------------------------------------------------------------------------------------
2019-12-24 12:10:46 [    INFO] test.unit.test_mocks: Testing mock dbconn (
PASSED                                                                                                                                                                                                                                                                   [ 76%]
test/unit/                                                                                           [100%]

=================================================================== 3 passed in 0.10s ===================================================================

Integration Tests

To run integration tests, you will need a mechanism to connect to a real qbo account. Save this info in a test_credentials.json file in your root directory:

  "client_id": "<client_id>",
  "client_secret": "<client_secret>",
  "realm_id": "<realm_id>",
  "refresh_token": "<refresh_token>",
  "environment": "<environment sandbox / production>"

Code coverage

To get code coverage report, run this command:

---------- coverage: platform darwin, python 3.7.4-final-0 -----------
Name                           Stmts   Miss  Cover
qbo_db_connector/       2      0   100%
qbo_db_connector/       79      3    96%
qbo_db_connector/          71      9    87%
TOTAL                            152     12    92%

To get an html report, run this command:

python -m pytest --cov=qbo_db_connector --cov-report html:cov_html

We want to maintain code coverage of more than 90% for this project at all times.

Please note that maintaining a score of 10 is important as the CI pylint action fails when a pull request is opened


This project is licensed under the MIT License - see the LICENSE file for details

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

qbo-db-connector-1.1.0.tar.gz (13.7 kB view hashes)

Uploaded Source

Built Distribution

qbo_db_connector-1.1.0-py3-none-any.whl (15.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page