A Polars adapter for your Salesforce data
Project description
posf
(poh ⋅ sef) A Salesforce client in Python for data engineers. Read from and write to Salesforce with Polars dataframes.
Usage
import posf
import polars as pl
# Connect to Salesforce
pf = posf.Posf.from_cli("prod")
# Describe table
pf.describe("Opportunity")
# Query
df: pl.DataFrame = pf.query("""
SELECT Id, Name
FROM Opportunity
""")
# Manipulate data in Polars dataframes
df = df.select(
[
pl.col("Id"),
pl.col("Name").str.to_titlecase()
]
)
# Write back to Salesforce
pf.update('Account', df)
Getting Started
First, add posf to your project.
uv add posf
Then, choose from any number of connection options.
from posf import Posf
import simple_salesforce
pf = Posf.from_cli() # Reuse `sf` CLI connection for local dev
pf = Posf.from_security_token() # Use security token for quick start
pf = Posf(simple_salesforce.Salesforce(...)) # Pass in a simple-salesforce
# client directly
Transactions
Use the composite_request API to work with ACID transactions.
tx = pf.composite_request()
tx.insert(df1)
tx.update(df2)
tx.delete(df3)
insert_res, update_res, delete_res = tx.commit()
Working with Notebooks
posf is specially designed with Marimo in mind. All of the non-idempotent actions may be gated behind a Marimo run button. This prevents executing the same action multiple times as cells are autorun. To do this, pass the run button's value property to the run parameter in any method that executes DML. These include insert, update, upsert, delete, and commit.
# Cell 1
import marimo as mo
import posf
# Cell 2
pf = posf.from_cli('prod')
run_button = mo.ui.run_button(label="Commit")
# Cell 3
# insert will not execute until run button is clicked
pf.insert(my_data, 'Account', run=run_button.value)
There are a number of examples available to illustrate this package. These can be loaded as Marimo snippets by saving the contents of examples/marimo-snippets to your snippets directory (snippets.custom_paths in marimo config show).
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file posf-0.1.1.tar.gz.
File metadata
- Download URL: posf-0.1.1.tar.gz
- Upload date:
- Size: 23.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b68a121d201ba54946aeb74b9c1fca05702c71dcc1efbce97c75e3dd71dd9db0
|
|
| MD5 |
a6f37a9c4858f1f376e3e80193d54c54
|
|
| BLAKE2b-256 |
417404e2afdfa75ee2f42247a80c1771ce7ab2e2ea9dfc6ecd37b5dfa506b673
|
File details
Details for the file posf-0.1.1-py3-none-any.whl.
File metadata
- Download URL: posf-0.1.1-py3-none-any.whl
- Upload date:
- Size: 25.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
109808c04872f4b697359476cf900fef0e92866a01927d6101b48e93e72313c8
|
|
| MD5 |
16dbb3ac64b4e31d55bfe48cf672c80c
|
|
| BLAKE2b-256 |
85d28e03002db1147c55381b5d7a92c795b87636c677eff860bce969bb41dc99
|