Skip to main content

No project description provided

Project description

SpawnDB

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 schemas, their 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.

# Sample usage for Pytest
from spawndb 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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spawndb-0.1.18.tar.gz (3.1 kB view hashes)

Uploaded Source

Built Distribution

spawndb-0.1.18-py3-none-any.whl (3.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page