NetSuite Database Connector
Warning: This project is undergoing active development and is not yet production-grade. Please mail the author if you want to find out more
Connects NetSuite 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 netsuite-db-connector
Usage
To use this connector you'll need connect to a NetSuite account via Token-based Authentication (TBA).
First, setup TBA credentials using environment variables.
# TBA credentials
export NS_ACCOUNT=xxxx
export NS_CONSUMER_KEY=xxxx
export NS_CONSUMER_SECRET=xxxx
export NS_TOKEN_KEY=xxxx
export NS_TOKEN_SECRET=xxxx
Here's example usage.
import os
import sqlite3
from netsuitesdk import NetSuiteConnection
from netsuite_db_connector import NetSuiteExtractConnector, NetSuiteLoadConnector
def ns_connect():
NS_ACCOUNT = os.getenv('NS_ACCOUNT')
NS_CONSUMER_KEY = os.getenv('NS_CONSUMER_KEY')
NS_CONSUMER_SECRET = os.getenv('NS_CONSUMER_SECRET')
NS_TOKEN_KEY = os.getenv('NS_TOKEN_KEY')
NS_TOKEN_SECRET = os.getenv('NS_TOKEN_SECRET')
nc = NetSuiteConnection(account=NS_ACCOUNT, consumer_key=NS_CONSUMER_KEY, consumer_secret=NS_CONSUMER_SECRET, token_key=NS_TOKEN_KEY, token_secret=NS_TOKEN_SECRET)
return nc
ns = ns_connect()
dbconn = sqlite3.connect('/tmp/ns.db', detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)
x = NetSuiteExtractConnector(ns=ns, dbconn=dbconn)
x.create_tables()
x.extract_currencies()
x.extract_accounts()
x.extract_departments()
x.extract_locations()
x.extract_vendors()
x.extract_classifications()
y = NetSuiteLoadConnector(ns=ns, dbconn=dbconn)
y.create_tables()
# do some transformations and populated vendor bills related load tables
for vendor_bill_external_id in y.get_vendor_bill_external_ids():
internal_id = y.load_vendor_bill(vendor_bill_external_id=vendor_bill_external_id)
print(f'posted vendor_bill_id {vendor_bill_external_id} for which NS returned {internal_id}')
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
- 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:
...
Integration Tests
To run unit tests, you will need to connect to a real NetSuite account. Set the following environment variables before running the integration tests:
# TBA credentials
export NS_ACCOUNT=xxxx
export NS_CONSUMER_KEY=xxxx
export NS_CONSUMER_SECRET=xxxx
export NS_TOKEN_KEY=xxxx
export NS_TOKEN_SECRET=xxxx
Code coverage
To get code coverage report, run this command:
python -m pytest --cov=netsuite_db_connector
<snipped output>
To get an html report, run this command:
python -m pytest --cov=netsuite_db_connector --cov-report html:cov_html
We want to maintain code coverage of more than 95% for this project at all times.
License
This project is licensed under the MIT License - see the LICENSE file for details
Metadata
Release files for netsuite-db-connector 0.3.1
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 | |
|---|---|---|---|---|
| netsuite-db-connector-0.3.1.tar.gz | 5.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| netsuite_db_connector-0.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.1 kB
Release files / netsuite-db-connector-0.3.1.tar.gz
| Download URL | netsuite-db-connector-0.3.1.tar.gz |
|---|---|
| Size | 5.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f5f0a2f4fe04aee78c702d9263adf82d5fd4baef768938e5ab8dc3dc3456caa6
|
|
BLAKE2b-256 checksum How to use checksums |
aebfe88c37b5f878fb975ed5b24ef353d5c6891a2df24766c94083e4eed9c3e0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.5.0.1 requests/2.25.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.8
|
Release files / netsuite_db_connector-0.3.1-py3-none-any.whl
| Download URL | netsuite_db_connector-0.3.1-py3-none-any.whl |
|---|---|
| Size | 7.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1e89dd1488bd58c3dbdd6b3defeadfe07cf626169f91404f415d76158703cbd9
|
|
BLAKE2b-256 checksum How to use checksums |
3abe8ac8fee8edae779ab651e860315a94f55752a22c9bc703b993018856b649
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.5.0.1 requests/2.25.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.8
|
Security for netsuite-db-connector 0.3.1
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.