Skip to main content

A python SDK for the dbt RPC server.

Project description

dbt-rpc-client

PyPI version PyPI - Status PyPI - Python Version PyPI - License Build Status

A python SDK for interacting with a dbt rpc server.

Installation

$ pip install dbt-rpc-client

Basic Usage

from dbt_rpc_client import DbtRpcClient
import requests

rpc = DbtRpcClient(hostname="0.0.0.0", port=8580)

# Getting the current status of the dbt rpc server.
response = rpc.status()
assert isinstance(response, requests.Response)
assert response.ok

# Running dbt models via CLI command.
response = rpc.cli(cli_args="dbt run --models @model1 +model2+")
assert response.ok

# Running dbt models via `run` method.
response = rpc.run(models=["@model1", "+model2+"])
assert response.ok

# Polling a dbt rpc operation.
response = rpc.poll(request_token=response.get("id"))
assert response.ok
print(response.get("result").get("status"))

# Compiling/Running a SQL query.
sql = """
select 1
from {{ ref("my_dbt_model") }}
"""

response = rpc.compile_sql(sql=sql, name="my_sql_query")
assert response.ok

response = rpc.run_sql(sql=sql, name="my_sql_query")
assert response.ok

Contributing

  1. The first step to contributing is getting a copy of the source code. First, fork dbt-rpc-client on GitHub. Then, cd into the directory where you want your copy of the source code to live and clone the source code:
$ cd repos
$ git clone git@github.com:YourGitHubName/dbt-rpc-client.git
  1. Now that you have a copy of the source code on your machine, create and activate a virtual envionment for dbt-rpc-client:
$ python3 -mvenv ~/.venvs/dbt-rpc-client
$ source ~/.venvs/dbt-rpc-client/bin/activate
  1. Once inside the virtual environment, run make dev_install at the root of the repository:
$ (dbt-rpc-client) make dev_install
  1. Run the tox testing suite in the appropriate python environment to ensure things are working properly:
$ (dbt-rpc-client) tox -e py37

To format your code using isort and flake8 before commiting changes, run the following commands:

$ (dbt-rpc-client) make isort
$ (dbt-rpc-client) make flake8

Once you've confirmed that your changes work and the testing suite passes, feel free to put out a PR!

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

dbt_rpc_client-0.1.0a1.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

dbt_rpc_client-0.1.0a1-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file dbt_rpc_client-0.1.0a1.tar.gz.

File metadata

  • Download URL: dbt_rpc_client-0.1.0a1.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.20.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.5

File hashes

Hashes for dbt_rpc_client-0.1.0a1.tar.gz
Algorithm Hash digest
SHA256 237c985b5abd7cf9b6003790f9cfce32044569dfcbb3de5eae2edab3265c31cf
MD5 50ba4faa4c61f626d6a97c80e834a712
BLAKE2b-256 a93cde7b25b32822ed764217d7e726b73f8a837a09a7dd0428bf7ebcde42a710

See more details on using hashes here.

File details

Details for the file dbt_rpc_client-0.1.0a1-py3-none-any.whl.

File metadata

  • Download URL: dbt_rpc_client-0.1.0a1-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.20.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.5

File hashes

Hashes for dbt_rpc_client-0.1.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 2633ad2b1e04e299099d2e3ea6961206f9ea70bae0ce9f915c49ec4aecb74784
MD5 04382051ec80356fb9fcfc6785c59bdd
BLAKE2b-256 c063c65372f4fcddb29bf394d3c2c13fda3a96068e880d8cc6af72c4604e1afc

See more details on using hashes here.

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