Skip to main content

SQLAlchemy Seeder

Project description

sqlalchemyseed

PyPI PyPI - Python Version PyPI - License Python package Maintainability codecov Documentation Status

Sqlalchemy seeder that supports nested relationships.

Supported file types

  • json
  • yaml
  • csv

Installation

Default installation

pip install sqlalchemyseed

Quickstart

main.py

from sqlalchemyseed import load_entities_from_json
from sqlalchemyseed import Seeder
from db import session

# load entities
entities = load_entities_from_json('data.json')

# Initializing Seeder
seeder = Seeder(session)

# Seeding
seeder.seed(entities)

# Committing
session.commit()  # or seeder.session.commit()

data.json

{
    "model": "models.Person",
    "data": [
        {
            "name": "John March",
            "age": 23
        },
        {
            "name": "Juan Dela Cruz",
            "age": 21
        }
    ]
}

Documentation

https://sqlalchemyseed.readthedocs.io/

Found Bug?

Report here in this link: https://github.com/jedymatt/sqlalchemyseed/issues

Want to contribute?

First, Clone this repository.

Install dev dependencies

Inside the folder, paste this in the terminal to install necessary dependencies:

pip install -r requirements.txt -r docs/requirements.txt

Note: make sure you have the virtual environment and enabled, or if you are using vs code and docker then you can simply re-open this as container.

Run tests

Before running tests, make sure that the package is installed as editable:

python setup.py develop --user

Then run the test:

pytest tests

Run test with coverage

coverage run -m pytest

Autobuild documentation

sphinx-autobuild docs docs/_build/html

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

sqlalchemyseed-2.0.0.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

sqlalchemyseed-2.0.0-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file sqlalchemyseed-2.0.0.tar.gz.

File metadata

  • Download URL: sqlalchemyseed-2.0.0.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for sqlalchemyseed-2.0.0.tar.gz
Algorithm Hash digest
SHA256 3482c878480fe1bd2903ef9de07ab0ebdf2b92676b271161e4808b97880a7222
MD5 4dce69231f3a8bea340411b157b47a53
BLAKE2b-256 693e3231fc11a8a189b647fde45bbcd9a8961fea72e57b5ace8325418730fa35

See more details on using hashes here.

File details

Details for the file sqlalchemyseed-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sqlalchemyseed-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 67cc2f43e02c1d187224e04eaf0be897160f8ab5138a901273b8d4cf93ef4068
MD5 5f8da243ef44f9805368dc7bb129f8c5
BLAKE2b-256 e826396a6e85cc5ab3580f4cdc5cec2779eb90b9c99c4cb74b4b479afcf42157

See more details on using hashes here.

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