Skip to main content

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

Project description

Xero Database Connector

Connects Xero 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 xero-db-connector
    

Usage

To use this connector you'll need Xero credentials - specifically the keyfile and consumer key.

Here's example usage. Note the detect_types part - this is essential for timestamp to be translated to datetime.datetime type.

from xero_db_connector.extract import XeroExtractConnector
import sqlite3
import logging
from xero import Xero
from xero.auth import PrivateCredentials

logging.basicConfig(
    format='%(asctime)s %(name)s%(message)s', level=logging.INFO)
dbconn = sqlite3.connect("/tmp/xero.db", detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)
xero_keyfile = 'XXX'
xero_consumer_key = 'XXX'
with open(xero_keyfile) as keyfile:
    rsa_key = keyfile.read()
credentials = PrivateCredentials(xero_consumer_key, rsa_key)
xero = Xero(credentials)
x = XeroExtractConnector(xero=xero, dbconn=dbconn)
x.create_tables()
x.extract_invoices()

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
      

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

xero-db-connector-0.2.0.tar.gz (4.7 kB view hashes)

Uploaded Source

Built Distribution

xero_db_connector-0.2.0-py3-none-any.whl (6.9 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