Welcome to dbt-postgres-python 👋 do more with dbt
dbt-postgres-python adapter is the ✨easiest✨ way to run your dbt Python models.
Starting with dbt v1.3, you can now build your dbt models in Python. This leads to some cool use cases that was once difficult to build with SQL alone. Some examples are:
- Using Python stats libraries to calculate stats
- Building forecasts
- Building other predictive models such as classification and clustering
This is fantastic! BUT, there is still one issue though! There is no Python support for Postgres. dbt-postgres-python provides the best environment to run your Python models that works with Postgres!
Project background
This project is based off the dbt-fal project. Thank you FAL-AI for starting that project. Priorities change and FAL-AI in April, 2024 chose to archive that project and focus their efforts elsewhere.
My team at work used dbt-fal, so that we could run python code on postgres. As dbt-fal was not being kept up-to-date with DBT, I chose to pick up that project and bring it up-to-date. As a result, this project will only support Postgres going forward. Support for the FAL CLI has also been dropped.
Getting Started
1. Install dbt-postgres-python
pip install dbt-postgres-python
2. Update your profiles.yml and add the fal adapter
jaffle_shop:
target: dev_with_fal
outputs:
dev_with_fal:
type: fal # "fal" type is kept for backwards compatibility
db_profile: dev_postgres # This points to your main adapter
dev_postgres:
type: postgres
...
Don't forget to point to your main adapter with the db_profile attribute. This is how the fal adapter knows how to connect to your data warehouse.
3. Add your python models
Add in your python models to your project just as you would your SQL models. Follow DBT's instructions on how to do so.
# a_python_model.py
import ...
def model(dbt, session):
my_sql_model_df = dbt.ref("my_sql_model")
final_df = ... # stuff you can't write in SQL!
return final_df
4. dbt run!
That is it! It is really that simple 😊
Metadata
Release files for dbt-postgres-python 1.7.17
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 | Actions |
|---|---|---|---|---|
| dbt_postgres_python-1.7.17.tar.gz | 28.6 kB | Without provenance | Details for dbt_postgres_python-1.7.17.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dbt_postgres_python-1.7.17-py3-none-any.whl | Python 3 | none | any | Details for dbt_postgres_python-1.7.17-py3-none-any.whl |
Total release size: 68.6 kB
Release files / dbt_postgres_python-1.7.17.tar.gz
| Download URL | dbt_postgres_python-1.7.17.tar.gz |
|---|---|
| Size | 28.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a79b249b7a1707a034d2b20300d183c7d24c01e3108f02e78c9b1d9f198a54b6
|
|
BLAKE2b-256 checksum How to use checksums |
57a1250521425490b25d735c07464bbcac521af80c251c0bbde37d8815a24d11
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.0 CPython/3.12.4
|
Release files / dbt_postgres_python-1.7.17-py3-none-any.whl
| Download URL | dbt_postgres_python-1.7.17-py3-none-any.whl |
|---|---|
| Size | 40.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5058bd25b16830c165638a83562611f8b5d1f185f9cfd60beba16fa8006b8a21
|
|
BLAKE2b-256 checksum How to use checksums |
cf8b4183d20b7d63a2e137213fb8c6125b92b9051b1348eb43902414844443a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.0 CPython/3.12.4
|
Security for dbt-postgres-python 1.7.17
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.