This release is a pre-release and may not be stable for production use.
investify-utils
Shared utilities for Investify services.
Installation
# Sync PostgreSQL client (psycopg3 + SQLAlchemy + pangres)
pip install investify-utils[postgres]
# Async PostgreSQL client (asyncpg + SQLAlchemy)
pip install investify-utils[postgres-async]
PostgreSQL Clients
Sync Client (PostgresClient)
Uses psycopg3 + SQLAlchemy for connection pooling, pangres for upsert.
from investify_utils.postgres import PostgresClient
client = PostgresClient(
host="localhost",
port=5432,
username="user",
password="pass",
database="db",
# SQLAlchemy pool options
pool_size=5,
pool_recycle=3600,
)
# Read
df = client.read("SELECT * FROM table")
# Insert (uses COPY protocol)
client.insert(df, table="my_table", schema="public")
# Upsert (DataFrame index = primary keys)
df = df.set_index(["id"])
client.upsert(df, table="my_table", schema="public")
# Execute DDL/DML
client.execute("DELETE FROM table WHERE id = 1")
# Close (important for Celery workers)
client.close()
Async Client (AsyncPostgresClient)
Uses asyncpg + SQLAlchemy async engine. Read-only.
from investify_utils.postgres import AsyncPostgresClient
client = AsyncPostgresClient(
host="localhost",
port=5432,
username="user",
password="pass",
database="db",
# SQLAlchemy pool options
pool_size=5,
pool_recycle=3600,
)
# In async context
df = await client.read("SELECT * FROM table")
await client.close()
# Or as context manager
async with AsyncPostgresClient(...) as client:
df = await client.read("SELECT * FROM table")
Celery Integration
Both clients use lazy initialization, safe for Celery prefork workers.
# instances/postgres_core.py
from investify_utils.postgres import PostgresClient
from config import settings
postgres_core = PostgresClient(**settings.postgres.model_dump())
# celery_app.py
from celery.signals import worker_process_init
@worker_process_init.connect
def init_worker(**_kwargs):
# Reset engine for each worker (optional with lazy init)
from instances.postgres_core import postgres_core
postgres_core.close()
Development
uv sync
uv run ruff check investify_utils/
Metadata
Release files for investify-utils 2.0.0a13
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 |
|---|---|---|---|---|
| investify_utils-2.0.0a13.tar.gz | 14.2 kB | Without provenance | Details for investify_utils-2.0.0a13.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| investify_utils-2.0.0a13-py3-none-any.whl | Python 3 | none | any | Details for investify_utils-2.0.0a13-py3-none-any.whl |
Total release size: 36.8 kB
Release files / investify_utils-2.0.0a13.tar.gz
| Download URL | investify_utils-2.0.0a13.tar.gz |
|---|---|
| Size | 14.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4b88168b6d9b9d7f09eeaff394aa3f37efb9e66372ae21cc055da4df3efd022e
|
|
BLAKE2b-256 checksum How to use checksums |
48ab0bdf46d84558cbacbc70556d2cbc265f7c187cef72a814af96959917b8d2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.0
|
Release files / investify_utils-2.0.0a13-py3-none-any.whl
| Download URL | investify_utils-2.0.0a13-py3-none-any.whl |
|---|---|
| Size | 22.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a801089e284e6394592c01f98216257dfe872a7df1fcb5d3f0a228fb5cff02f5
|
|
BLAKE2b-256 checksum How to use checksums |
f2e56be45b38914b07f99994758e549594ba0bb8115d83c82d96d7de0177f239
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.0
|
Security for investify-utils 2.0.0a13
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.