File tree Expand file tree Collapse file tree 4 files changed +56
-36
lines changed
Expand file tree Collapse file tree 4 files changed +56
-36
lines changed Original file line number Diff line number Diff line change 1- .. currentmodule :: sqlalchemyseed
2-
31API Reference
42=============
53
64Seeders
7- --------------
5+ -------
86
9- .. autoclass :: seeder .Seeder
7+ .. autoclass :: sqlalchemyseed .Seeder
108 :members:
119 :undoc-members:
1210
13- .. autoclass :: seeder .HybridSeeder
11+ .. autoclass :: sqlalchemyseed .HybridSeeder
1412 :members:
1513 :undoc-members:
1614
1715Loaders
1816-------
1917
20- .. automodule :: loader
21- :members:
22- :undoc-members:
18+ .. autofunction :: sqlalchemyseed.load_entities_from_json
19+
20+ .. autofunction :: sqlalchemyseed.load_entities_from_yaml
21+
22+ .. autofunction :: sqlalchemyseed.load_entities_from_csv
23+
2324
2425Validators
2526----------
2627
27- .. autoclass :: validator.SchemaValidator
28- :members:
29-
30- .. autofunction :: validator.validate
28+ .. autofunction :: sqlalchemyseed.validator.validate
3129
3230
33- .. autofunction :: validator.hybrid_validate
31+ .. autofunction :: sqlalchemyseed. validator.hybrid_validate
3432
3533
3634Exceptions
3735----------
3836
39- .. automodule :: errors
37+ .. automodule :: sqlalchemyseed. errors
4038 :members:
Original file line number Diff line number Diff line change 2828# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
2929# ones.
3030extensions = [
31- 'sphinx.ext.autodoc'
31+ 'sphinx.ext.autodoc' ,
3232]
3333
3434# Add any paths that contain templates here, relative to this directory.
Original file line number Diff line number Diff line change 66 Welcome to sqlalchemyseed's documentation!
77==========================================
88
9- sqlalchemyseed is a SQLAlchemy seeder that supports nested relationships
10- with an easy to read text files.
11-
12- Contents
13- ========
14-
159.. toctree ::
1610 :maxdepth: 2
11+ :caption: Contents
1712
1813 intro
1914 api
Original file line number Diff line number Diff line change @@ -10,10 +10,50 @@ Supported file types.
1010- yaml
1111- csv
1212
13- Example of json file
13+ Installation
14+ ------------
15+
16+ Default installation
17+
18+ .. code-block :: console
19+
20+ pip install sqlalchemyseed
21+
22+ When using yaml to load entities from yaml files,
23+ execute this command to install necessary dependencies
24+
25+ .. code-block :: console
26+
27+ pip install sqlalchemyseed[yaml]
28+
29+ Getting Started
30+ ---------------
31+
32+ Here's a simple snippet to get started from :code: `main.py ` file.
33+
34+ .. code-block :: python
35+
36+ from sqlalchemyseed import load_entities_from_json
37+ from sqlalchemyseed import Seeder
38+ from db import session
39+
40+ # load entities
41+ entities = load_entities_from_json(' data.json' )
1442
15- .. code-block :: json
43+ # Initializing Seeder
44+ seeder = Seeder(session)
1645
46+ # Seeding
47+ seeder.seed(entities)
48+
49+ # Committing
50+ session.commit() # or seeder.session.commit()
51+
52+
53+ And the :code: `data.json ` file.
54+
55+ .. code-block :: json
56+
1757 {
1858 "model" : " models.Person" ,
1959 "data" : [
@@ -27,16 +67,3 @@ Example of json file
2767 }
2868 ]
2969 }
30-
31-
32- Installation
33- ------------
34-
35- Default installation ::
36-
37- pip install sqlalchemyseed
38-
39- When using yaml to load entities from yaml files,
40- execute this command to install necessary dependencies ::
41-
42- pip install sqlalchemyseed[yaml]
You can’t perform that action at this time.
0 commit comments