Package: qbo-db-connector
Quickbooks Online Database ConnectorConnects Quickbooks online to a database to transfer information to and fro.InstallationThis project requiresPython 3+.Download this project and use it (copy it in your project, etc).Install it frompip.$ pip install qbo-db-connectorUsageTo use this connector you'll need these Quickbooks credentials used for OAuth2 authentication:client ID,client secretandrefresh token.This connector is very easy to use.importloggingimportsqlite3fromqbosdkimportQuickbooksOnlineSDKfromqbo_db_connectorimportQuickbooksExtractConnector,QuickbooksLoadConnectordbconn=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 tokenrefresh_token=connection.refresh_token# extractingquickbooks_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()# loadingquickbooks_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')ContributeTo contribute to this project follow the stepsFork and clone the repository.Runpip install -r requirements.txtSetup pylint precommit hookCreate a file.git/hooks/pre-commitCopy and paste the following lines in the file -#!/usr/bin/env bashgit-pylint-commit-hookRunchmod +x .git/hooks/pre-commitMake necessary changesRun unit tests to ensure everything is fineUnit TestsTo run unit tests, run pytest in the following manner:python -m pytest test/unitYou 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 TestsTo 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 coverageTo get code coverage report, run this command:----------coverage:platformdarwin,python3.7.4-final-0-----------
NameStmtsMissCover
--------------------------------------------------
qbo_db_connector/__init__.py20100%
qbo_db_connector/extract.py79396%
qbo_db_connector/load.py71987%
--------------------------------------------------
TOTAL1521292%To get an html report, run this command:python-mpytest--cov=qbo_db_connector--cov-reporthtml:cov_htmlWe 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 openedLicenseThis project is licensed under the MIT License - see theLICENSEfile for details