Skip to content

Commit 1a59923

Browse files
committed
add quickstart
1 parent d203e9d commit 1a59923

2 files changed

Lines changed: 66 additions & 1 deletion

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2+
[![Klv1Zcx.md.png](https://iili.io/Klv1Zcx.md.png)](https://freeimage.host/i/Klv1Zcx)
3+
14
# TinyPG
25

36
A Python package for creating ephemeral PostgreSQL databases, inspired by [ephemeralpg](https://github.com/eradman/ephemeralpg).

src/tinypg/__init__.py

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,69 @@
11
"""
2+
[![Klv1Zcx.md.png](https://iili.io/Klv1Zcx.md.png)](https://freeimage.host/i/Klv1Zcx)
3+
24
TinyPG: Ephemeral PostgreSQL databases for Python development and testing.
35
4-
Based on ephemeralpg by Eric Radman, reimplemented in pure Python.
6+
TinyPG provides a clean Python API for creating temporary PostgreSQL databases for development and testing. It's designed to be self-contained and work without requiring system-wide PostgreSQL installation.
7+
8+
## Features
9+
10+
- **Pure Python**: Takes care of downloading portable postgresql binaries for you
11+
- **Fast startup**: Fast database initialization
12+
- **Development-focused**: Perfect for writing python integrations tests against postgres without having to configure it in your environment
13+
- **Good dev UX**: Context managers and pytest fixtures & works seamlessly with your existing code (SQLAlchemy, async ...)
14+
- **(Optional) Supports compiling postgres from sources**: if you're not comfortable pulling prebuilt binaries from the internet
15+
16+
## Installation
17+
18+
You can install TinyPG from PyPI using your preferred Python packaging tool:
19+
20+
```bash
21+
# Using pip
22+
pip install tinypg
23+
24+
# Using uv
25+
uv pip install tinypg
26+
```
27+
28+
The package provides optional extras for asynchronous drivers and development
29+
tooling. For example, to install the async dependencies with uv:
30+
31+
```bash
32+
uv pip install "tinypg[async]"
33+
```
34+
35+
## Quick Start
36+
37+
```python
38+
import tinypg
39+
40+
# Simple usage with context manager
41+
with tinypg.database() as db_uri:
42+
import psycopg2
43+
conn = psycopg2.connect(db_uri)
44+
# Use database...
45+
# Database automatically cleaned up
46+
47+
# Advanced usage
48+
db = tinypg.EphemeralDB(port=5433, cleanup_timeout=300)
49+
uri = db.start()
50+
try:
51+
# Use database...
52+
pass
53+
finally:
54+
db.stop()
55+
```
56+
57+
## Requirements
58+
59+
- Python 3.8+
60+
- PostgreSQL source compilation tools (if binaries need to be built)
61+
62+
## Github repository
63+
64+
TinyPG's github repository is available there:
65+
[Github repository](https://github.com/kketch/tinypg)
66+
567
"""
668

769
from .config import TinyPGConfig

0 commit comments

Comments
 (0)