Metadata-Version: 2.4
Name: psycopg2_loio
Version: 1.0
Summary: Wrap psycopg2 lobjects as Python IO
Author: James Howe
License-Expression: MIT
Project-URL: Homepage, https://github.com/OrangeDog/psycopg2_loio
Project-URL: Issues, https://github.com/OrangeDog/psycopg2_loio/issues
Classifier: Development Status :: 5 - Production/Stable
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Operating System :: OS Independent
Classifier: Topic :: Database :: Front-Ends
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: psycopg2>=2.0.8
Dynamic: license-file

# psycopg2_loio

Wrap an `lobject` (PostgreSQL Large Object) with a file-like interface.

Installation
------------
```sh
pip install psycopg2_loio
```

Usage
-----
```python
import shutil

import psycopg2
import psycopg2_loio

with psycopg2.connect() as conn:
    with psycopg2_loio.as_binary(conn.lobject(1234, mode='wb') as lo:
        with open('file.bin', 'rb') as file:
            shutil.copyfileobj(file, lo)
    conn.commit()

    with psycopg2_loio.as_text(conn.lobject(4567, mode='rb'),
                               encoding='ascii',
                               errors='replace') as lo:
        for line in lo:
            print(line.strip()))
```
