|
1 | 1 | # Py-PGlite |
2 | 2 |
|
3 | | -<img src="https://github.com/user-attachments/assets/3c6ef886-5075-4d82-a180-a6b1dafe792b" alt="py-pglite Logo" width="60" align="left" style="margin-right: 16px;"/> |
4 | | - |
5 | | -**Instant PostgreSQL for Python testing** ⚡ |
6 | | - |
7 | | -`pip install py-pglite` |
8 | | - |
9 | | -<br clear="all"/> |
10 | | - |
11 | | -```python |
12 | | -def test_users(pglite_session): |
| 3 | +<div style="display: flex; align-items: flex-start;"> |
| 4 | + <div style="flex: 0 0 auto; margin-right: 18px;"> |
| 5 | + <img src="https://github.com/user-attachments/assets/3c6ef886-5075-4d82-a180-a6b1dafe792b" alt="py-pglite Logo" width="160" style="border-radius: 8px;"/> |
| 6 | + </div> |
| 7 | + <div style="flex: 1;"> |
| 8 | + <p><strong>Instant PostgreSQL for Python testing</strong> ⚡</p> |
| 9 | + <p><code>pip install py-pglite</code></p> |
| 10 | + <pre><code class="language-python">def test_users(pglite_session): |
13 | 11 | user = User(name="Alice") |
14 | 12 | pglite_session.add(user) |
15 | 13 | pglite_session.commit() |
16 | | - assert user.id == 1 # It's real PostgreSQL! |
17 | | -``` |
| 14 | + assert user.id == 1 # It's real PostgreSQL!</code></pre> |
| 15 | + <p><strong>That's it.</strong> No Docker, no setup, no config files. Real PostgreSQL, instant testing.</p> |
| 16 | + </div> |
| 17 | +</div> |
18 | 18 |
|
19 | | -**That's it.** No Docker, no setup, no config files. Real PostgreSQL, instant testing. |
| 19 | +<br clear="all"/> |
20 | 20 |
|
21 | 21 | [](https://github.com/wey-gu/py-pglite/actions/workflows/ci.yml) [](https://badge.fury.io/py/py-pglite) [](https://pypi.org/project/py-pglite/) |
22 | 22 |
|
@@ -254,21 +254,25 @@ pytest tests/django/ # Auto-isolated |
254 | 254 | --- |
255 | 255 |
|
256 | 256 | <<<<<<< HEAD |
| 257 | + |
257 | 258 | # Custom configuration |
| 259 | + |
258 | 260 | config = PGliteConfig( |
259 | 261 | timeout=30, |
260 | 262 | cleanup_on_exit=True, |
261 | 263 | log_level="DEBUG" |
262 | 264 | ) |
263 | 265 |
|
264 | 266 | # Manual management |
| 267 | + |
265 | 268 | with PGliteManager(config) as manager: |
266 | 269 | engine = manager.get_engine() |
267 | 270 | SQLModel.metadata.create_all(engine) |
268 | | - |
| 271 | + |
269 | 272 | with Session(engine) as session: |
270 | 273 | # Your database operations here |
271 | 274 | pass |
| 275 | + |
272 | 276 | ``` |
273 | 277 |
|
274 | 278 | ## 🔧 Features |
@@ -474,6 +478,7 @@ def test_with_custom_cleanup(pglite_engine): |
474 | 478 | # Custom cleanup if needed |
475 | 479 | utils.clean_database_data(pglite_engine) |
476 | 480 | ``` |
| 481 | + |
477 | 482 | ======= |
478 | 483 | *py-pglite: Because testing should be simple.* ⚡ |
479 | 484 | >>>>>>> 7555fb5 (feat & refactor: decouple sqlalchemy, introduce django & pytest-django) |
0 commit comments