IPython magic to use dbt
Project description
dbt-iPy
Run dbt commands inside a IPython session.
Installation
pip install dbt-ipy
Tutorial
You can access the tutorial notebook here
Quickstart Guide
Load the extension
%load_ext dbt-ipy
Connect to dbt RPC
The next thing you'll probably want to do is to run a dbt RPC server in the background. That will let you run queries, compile SQL code among other things:
%dbt rpc <args>
(the args will be passed directly to dbt as command line arguments)
The two most important parameters would be:
--port [port_number]
Passing this parameter will run the dbt RPC on that port. Default is 8580--existing
This will skip creating a new dbt RPC and instead it will connect to an existing one on the specified port
Custom magic commands
Compiling queries
The sql query in the cell will be compiled with the dbt RPC server and IPython will output the text::
%%compile_sql
SELECT ...
Running queries
The sql query in the cell will be run on the dbt RPC server and IPython will output the agate table. Also, it will run its .print_table()
method::
%%run_sql
SELECT ...
Copying to clipboard
It is also possible to copy the last result returned by dbt to the clipboard. If that's a %%compile_sql
compiled query it will return the SQL text but if it's a %%run_sql
table, it will transform it to CSV and copy that to the clipboard. You can then paste the contents of the clipboard into a spreadsheet as usual.
%dbt_clipboard
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file dbt-ipy-1.0.1.tar.gz
.
File metadata
- Download URL: dbt-ipy-1.0.1.tar.gz
- Upload date:
- Size: 17.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 283d7c55291ceec8814654ebf4567deb59cec051042dca7c04b6762619fc257a |
|
MD5 | a8417c0df9e7b46748d759d43ec925a2 |
|
BLAKE2b-256 | 4128534698fc50958f6ea3cfeb3e6a205c73da967b372c529beca2a3a5392b5a |
File details
Details for the file dbt_ipy-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: dbt_ipy-1.0.1-py3-none-any.whl
- Upload date:
- Size: 17.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 67e43b0e8e6f4c13b7eb15258b01aba298cc53d9a21c88b04d8560d4a4ff5f48 |
|
MD5 | 1d5f3694c1661c8daacbb86cb4ee97aa |
|
BLAKE2b-256 | 35fabf67412f351b1281e97175cc616031fdc992d40a0f02e6c8e390dede8fe1 |