Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jedymatt/sqlalchemyseed
SQLAlchemy Seeder
https://github.com/jedymatt/sqlalchemyseed
csv json orm python seed seeder sqlalchemy sqlalchemy-orm sqlalchemy-python yaml
Last synced: 6 days ago
JSON representation
SQLAlchemy Seeder
- Host: GitHub
- URL: https://github.com/jedymatt/sqlalchemyseed
- Owner: jedymatt
- License: mit
- Created: 2021-06-20T12:49:43.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-12T03:47:34.000Z (over 1 year ago)
- Last Synced: 2024-09-24T02:04:23.213Z (10 days ago)
- Topics: csv, json, orm, python, seed, seeder, sqlalchemy, sqlalchemy-orm, sqlalchemy-python, yaml
- Language: Python
- Homepage: https://sqlalchemyseed.readthedocs.io/
- Size: 370 KB
- Stars: 14
- Watchers: 2
- Forks: 1
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# sqlalchemyseed
[![PyPI](https://img.shields.io/pypi/v/sqlalchemyseed)](https://pypi.org/project/sqlalchemyseed)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/sqlalchemyseed)](https://pypi.org/project/sqlalchemyseed)
[![PyPI - License](https://img.shields.io/pypi/l/sqlalchemyseed)](https://github.com/jedymatt/sqlalchemyseed/blob/main/LICENSE)
[![Python package](https://github.com/jedymatt/sqlalchemyseed/actions/workflows/python-package.yml/badge.svg)](https://github.com/jedymatt/sqlalchemyseed/actions/workflows/python-package.yml)
[![Maintainability](https://api.codeclimate.com/v1/badges/2ca97c98929b614658ea/maintainability)](https://codeclimate.com/github/jedymatt/sqlalchemyseed/maintainability)
[![codecov](https://codecov.io/gh/jedymatt/sqlalchemyseed/branch/main/graph/badge.svg?token=W03MFZ2FAG)](https://codecov.io/gh/jedymatt/sqlalchemyseed)
[![Documentation Status](https://readthedocs.org/projects/sqlalchemyseed/badge/?version=latest)](https://sqlalchemyseed.readthedocs.io/en/latest/?badge=latest)Sqlalchemy seeder that supports nested relationships.
Supported file types
- json
- yaml
- csv## Installation
Default installation
```shell
pip install sqlalchemyseed
```## Quickstart
main.py
```python
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
```json
{
"model": "models.Person",
"data": [
{
"name": "John March",
"age": 23
},
{
"name": "Juan Dela Cruz",
"age": 21
}
]
}
```## Documentation
## Found Bug?
Report here in this link:
## Want to contribute?
First, Clone this [repository](https://github.com/jedymatt/sqlalchemyseed).
### Install dev dependencies
Inside the folder, paste this in the terminal to install necessary dependencies:
```shell
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:
```shell
python setup.py develop --user
```Then run the test:
```shell
pytest tests
```Run test with coverage
```shell
coverage run -m pytest
```Autobuild documentation
```shell
sphinx-autobuild docs docs/_build/html
```