Metadata-Version: 2.1
Name: spawndb
Version: 0.1.16
Summary: 
Author: Pablo Prieto
Author-email: pabloprieto@live.com
Requires-Python: >=3.9,<4.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Requires-Dist: SQLAlchemy[asyncio] (>=1.4.31,<2.0.0)
Description-Content-Type: text/markdown

# TestDB

This is a simple library that helps in the creation of test databases for Python
projects that use SQLAlchemy.

It's aim it's to seamlessly handle creation of a separate test database, including
the creation of all schema objects and finally, handling the destruction of the test
database when it's no longer needed.

# Usage
To create a test database, use the init_test_db function.

This function expects two arguments:  
   - *database_url*: sqlalchemy.engine.URL  
   - *metadata*: sqlalchemy.schema.MetaData

It will return an instantiated Engine for the test database which you can use for 
your database logics.

```python
# Sample usage for Pytest
from testdb import init_test_db, destroy_test_db

def my_cool_test():
    db_engine = init_test_db(database_url, sqla_metadata)
    
    try:
        # your stuff goes here
    
    finally:
        destroy_test_db(database_url)
```


