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: 4 months ago
JSON representation
SQLAlchemy Seeder
- Host: GitHub
- URL: https://github.com/jedymatt/sqlalchemyseed
- Owner: jedymatt
- License: mit
- Created: 2021-06-20T12:49:43.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-03-12T03:47:34.000Z (about 2 years ago)
- Last Synced: 2025-01-31T13:43:40.004Z (4 months 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
[](https://pypi.org/project/sqlalchemyseed)
[](https://pypi.org/project/sqlalchemyseed)
[](https://github.com/jedymatt/sqlalchemyseed/blob/main/LICENSE)
[](https://github.com/jedymatt/sqlalchemyseed/actions/workflows/python-package.yml)
[](https://codeclimate.com/github/jedymatt/sqlalchemyseed/maintainability)
[](https://codecov.io/gh/jedymatt/sqlalchemyseed)
[](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
```