semvec/pypi-packages huggingface dataset:
sqlalchemy-postgres-rls 0.1.1
Manage Postgres RLS policies in SQLAlchemy
Requires Python: >=3.11

# sqlalchemy-postgres-rls

PostgreSQL Row-Level Security (RLS) integration for SQLAlchemy, with optional Alembic autogeneration support.

---

## ✨ Features

- ✅ Define Postgres RLS policies declaratively using decorators on sqlalchemy/sqlmodel classes
- ✅ Optional Alembic integration via `[alembic]` extra
- ✅ Automatic `CREATE POLICY` / `DROP POLICY` generation

---

## 📦 Installation

### Core only

```bash
uv pip install sqlalchemy-postgres-rls
```

### With Alembic integration

```bash
uv pip install sqlalchemy-postgres-rls[alembic]
```

---

## 🧱 Defining RLS Policies

### Option 2: `@rls_policy` Decorator

```python
from sqlalchemy_postgres_rls.policy import rls_policy

@rls_policy(
    name="read_only_own_docs",
    command="SELECT",
    roles=["app_user"],
    using=lambda cls: cls.owner_id == func.current_setting("app.current_user_id").cast(int),
    with_check=lambda cls: cls.owner_id == func.current_setting("app.current_user_id").cast(int)
)
class UserDoc(SQLModel, table=True):
    id: int = Field(primary_key=True)
    owner_id: int
    content: str
```

---

## ⚙️ Alembic Integration

### 1. Enable the autogeneration hook

In your Alembic `env.py`:

```python
from sqlalchemy_postgres_rls.alembic_support import process_revision_directives

context.configure(
    ...,
    process_revision_directives=process_revision_directives,
)
```

### 2. Generate a migration

```bash
alembic revision --autogenerate -m "Add RLS policies"
```

This will include `op.execute("CREATE POLICY ...")` statements in the migration.

### 3. Downgrade support

Each policy will generate a corresponding `DROP POLICY IF EXISTS` in the `downgrade()` block.

---

## 🔍 How It Works

- RLS policies are defined as SQLAlchemy `SchemaItem`s and compiled via `@compiles(RLSPolicy)`
- They are registered to a global runtime registry
- Alembic picks them up during autogeneration and injects the appropriate DDL

---

## 🧪 Roadmap

- [ ] Policy diffing from live database
- [ ] ALTER POLICY support
- [ ] Policy sets and reusable templates

---

## 📄 License

MIT

---

## 💬 Feedback

Open an issue or pull request on GitHub! Contributions are welcome.
beancount-no-sparebank1 0.2.0
A library that converts financial data from SpareBank 1 into structured Beancount accounting format.
Requires Python: >=3.12

# beancount-no-sparebank1

A Python library for importing SpareBank 1 (Norway) bank data into Beancount accounting format.

![sb12](https://github.com/user-attachments/assets/e0e90691-1430-4bd1-a29d-e1605e30b857)


## Features

- Import transactions from CSV exports of SpareBank 1 deposit accounts
- Extract balance statements from PDF account statements ("kontoutskrift")
- Flexible transaction categorization with customizable rules

## Quick start

``` python
import beangulp
import beancount_no_sparebank1

importers = [
    beancount_no_sparebank1.deposit.DepositAccountImporter(
        'Assets:Checking',
        currency='NOK',
        narration_to_account_mappings=[
            ('GITHUB', 'Expenses:Cloud-Services:Source-Hosting:Github'),
            ('Fedex', 'Expenses:Postage:FedEx'),
            ('FREMTIND', 'Expenses:Insurance'),
        ]
    ),
    beancount_no_sparebank1.balance.PDFStatementImporter(
        'Assets:Checking',
        currency='NOK'
    ),
]

if __name__ == '__main__':
    ingest = beangulp.Ingest(importers)
    ingest()
```

## See also

- [Automatically balancing Beancount DKB transactions](https://sgoel.dev/posts/automatically-balancing-beancount-dkb-transactions/)
- [siddhantgoel/beancount-dkb](https://github.com/siddhantgoel/beancount-dkb)
PyEyeHealth 0.0.3
PyEyeHealth, göz sağlığını analiz etmeye yönelik bir araçtır.
Requires Python: >=3.6


wintitle = "Your title"
wincolor = "your own color"
ok_button_color = "your own color"
stop_button_color = "your own color"
default_text = "⚠️ Your eyes are too close to the screen!\nProlonged exposure can lead to complications."
predictor_path = r"shape_predictor_68_face_landmarks.dat"