Quickbooks Online Database Connector
Connects Quickbooks online to a database to transfer information to and fro.
Installation
This project requires Python 3+.
-
Download this project and use it (copy it in your project, etc).
-
Install it from pip.
$ 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.
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 -
#!/usr/bin/env bash git-pylint-commit-hook - Run
chmod +x .git/hooks/pre-commit
- Create a file
- 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 (test_mocks.py:18)
PASSED [ 69%]
test/unit/test_mocks.py::test_dbconn_mock_setup
-------------------------------------------------------------------------------------------------------------------------------- live log call ---------------------------------------------------------------------------------------------------------------------------------
2019-12-24 12:10:46 [ INFO] test.unit.test_mocks: Testing mock dbconn (test_mocks.py:29)
PASSED [ 76%]
test/unit/test_mocks.py::test_qec_mock_setup [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/__init__.py 2 0 100%
qbo_db_connector/extract.py 79 3 96%
qbo_db_connector/load.py 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
License
This project is licensed under the MIT License - see the LICENSE file for details
Metadata
Release files for qbo-db-connector 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| qbo-db-connector-1.1.0.tar.gz | 13.7 kB | Without provenance | Details for qbo-db-connector-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| qbo_db_connector-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for qbo_db_connector-1.1.0-py3-none-any.whl |
Total release size: 29.2 kB
Release files / qbo-db-connector-1.1.0.tar.gz
| Download URL | qbo-db-connector-1.1.0.tar.gz |
|---|---|
| Size | 13.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ac0ec0b8dd4e7abaf1db6c79a0770066e0adfc644ee3ab06fdfee3dc90b7260d
|
|
BLAKE2b-256 checksum How to use checksums |
83d435e7ab910e84d51b8933fd88dc75bfd582623bbae2aa6c8cdca87c63204c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6
|
Release files / qbo_db_connector-1.1.0-py3-none-any.whl
| Download URL | qbo_db_connector-1.1.0-py3-none-any.whl |
|---|---|
| Size | 15.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fd7d7dabbdbd15594b96bfb62b2a3a4ae782e9e5b67cedd203a3156b10e10632
|
|
BLAKE2b-256 checksum How to use checksums |
fc560f749c22e17ece88e1a1b44dc8c3813271179cb2d05039e5e2fd285e2e03
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6
|
Security for qbo-db-connector 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.