This project demonstrates how to use OpenDAL Python binding to interact with PostgreSQL as a key-value storage backend. OpenDAL (Open Data Access Layer) provides a unified API for accessing various storage services, making it easy to switch between different backends with minimal code changes.
- Python 3.12 or higher
- Docker and Docker Compose
- uv for Python package management
- Clone this repository:
git clone https://github.com/Xuanwo/opendal-python-postgresql-example.git
cd opendal-python-postgresql-example- Install dependencies using uv:
uv pip install -e .- Start the PostgreSQL container:
docker-compose up -dThis will start a PostgreSQL server and initialize it with the required schema and test data.
Execute the main script:
python main.pyThe example script demonstrates:
- Connecting to PostgreSQL using OpenDAL
- Writing data to the PostgreSQL backend
- Reading data from PostgreSQL
- Checking if objects exist
- Deleting objects
MIT