Skip to main content

Connects NetSuite to a database connector to transfer information to and fro

Project description

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+.

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

  2. 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
      
  • 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

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

netsuite-db-connector-0.1.2.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

netsuite_db_connector-0.1.2-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file netsuite-db-connector-0.1.2.tar.gz.

File metadata

  • Download URL: netsuite-db-connector-0.1.2.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.0 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.7.4

File hashes

Hashes for netsuite-db-connector-0.1.2.tar.gz
Algorithm Hash digest
SHA256 ee613e6bf9b8dfd5dea8ecb0447756b8da699cb811bd232e8e94203bc3bdc316
MD5 c9662e4c36c645a91ddfb78032332267
BLAKE2b-256 3f862c38c60a5b5a4b89b29004c1ac1b866d33dec32ee679ad2b114dc2073321

See more details on using hashes here.

File details

Details for the file netsuite_db_connector-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: netsuite_db_connector-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.0 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.7.4

File hashes

Hashes for netsuite_db_connector-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c2ab341be16944f5e0de9d32910110c985b263318fd26bcc40e273b77904bd4a
MD5 6ec2add67fa889368aea08a63c3ad96b
BLAKE2b-256 b0c125b3f775873dd0e9243015adfde02919aa6b64cae5ac2a14a7591f7e16fe

See more details on using hashes here.

Supported by

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