exdrf-al 0.1.8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- exdrf_al-0.1.8/PKG-INFO +133 -0
- exdrf_al-0.1.8/README.md +99 -0
- exdrf_al-0.1.8/exdrf_al/__init__.py +0 -0
- exdrf_al-0.1.8/exdrf_al/__version__.py +24 -0
- exdrf_al-0.1.8/exdrf_al/al2r_read.py +531 -0
- exdrf_al-0.1.8/exdrf_al/base.py +92 -0
- exdrf_al-0.1.8/exdrf_al/calc_q.py +350 -0
- exdrf_al-0.1.8/exdrf_al/click_support/__init__.py +10 -0
- exdrf_al-0.1.8/exdrf_al/click_support/auto_db_migration.py +85 -0
- exdrf_al-0.1.8/exdrf_al/click_support/downgrade_db.py +47 -0
- exdrf_al-0.1.8/exdrf_al/click_support/get_base.py +20 -0
- exdrf_al-0.1.8/exdrf_al/click_support/get_conn.py +41 -0
- exdrf_al-0.1.8/exdrf_al/click_support/get_dset.py +23 -0
- exdrf_al-0.1.8/exdrf_al/click_support/list_db_version.py +30 -0
- exdrf_al-0.1.8/exdrf_al/click_support/set_db_version.py +43 -0
- exdrf_al-0.1.8/exdrf_al/click_support/upgrade_db.py +54 -0
- exdrf_al-0.1.8/exdrf_al/connection.py +382 -0
- exdrf_al-0.1.8/exdrf_al/db_ver/__init__.py +0 -0
- exdrf_al-0.1.8/exdrf_al/db_ver/alembic/env.py +125 -0
- exdrf_al-0.1.8/exdrf_al/db_ver/alembic/script.py.mako +28 -0
- exdrf_al-0.1.8/exdrf_al/db_ver/db_ver.py +316 -0
- exdrf_al-0.1.8/exdrf_al/export.py +246 -0
- exdrf_al-0.1.8/exdrf_al/loader.py +502 -0
- exdrf_al-0.1.8/exdrf_al/persist.py +244 -0
- exdrf_al-0.1.8/exdrf_al/py.typed +0 -0
- exdrf_al-0.1.8/exdrf_al/schema_comp.py +239 -0
- exdrf_al-0.1.8/exdrf_al/table_counter.py +68 -0
- exdrf_al-0.1.8/exdrf_al/tools.py +228 -0
- exdrf_al-0.1.8/exdrf_al/ua_companion.py +41 -0
- exdrf_al-0.1.8/exdrf_al/utils.py +86 -0
- exdrf_al-0.1.8/exdrf_al/visitor.py +125 -0
- exdrf_al-0.1.8/exdrf_al.egg-info/PKG-INFO +133 -0
- exdrf_al-0.1.8/exdrf_al.egg-info/SOURCES.txt +46 -0
- exdrf_al-0.1.8/exdrf_al.egg-info/dependency_links.txt +1 -0
- exdrf_al-0.1.8/exdrf_al.egg-info/requires.txt +22 -0
- exdrf_al-0.1.8/exdrf_al.egg-info/top_level.txt +3 -0
- exdrf_al-0.1.8/exdrf_al_tests/__init__.py +0 -0
- exdrf_al-0.1.8/exdrf_al_tests/base_test.py +120 -0
- exdrf_al-0.1.8/exdrf_al_tests/calc_q_test.py +371 -0
- exdrf_al-0.1.8/exdrf_al_tests/conftest.py +147 -0
- exdrf_al-0.1.8/exdrf_al_tests/connection_test.py +205 -0
- exdrf_al-0.1.8/exdrf_al_tests/loader_test.py +472 -0
- exdrf_al-0.1.8/exdrf_al_tests/persist_test.py +151 -0
- exdrf_al-0.1.8/exdrf_al_tests/schema_comp_test.py +157 -0
- exdrf_al-0.1.8/exdrf_al_tests/ua_companion_test.py +41 -0
- exdrf_al-0.1.8/pyproject.toml +72 -0
- exdrf_al-0.1.8/setup.cfg +4 -0
- exdrf_al-0.1.8/setup.py +6 -0
exdrf_al-0.1.8/PKG-INFO
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: exdrf-al
|
|
3
|
+
Version: 0.1.8
|
|
4
|
+
Summary: Use SQLAlchemy with Ex-DRF.
|
|
5
|
+
Author-email: Nicu Tofan <nicu.tofan@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Classifier: Operating System :: OS Independent
|
|
8
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Typing :: Typed
|
|
11
|
+
Requires-Python: >=3.12.2
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
Requires-Dist: SQLAlchemy>=2.0.38
|
|
14
|
+
Requires-Dist: sqlparse>=0.5.3
|
|
15
|
+
Requires-Dist: alembic>=1.16.1
|
|
16
|
+
Requires-Dist: unidecode
|
|
17
|
+
Requires-Dist: exdrf
|
|
18
|
+
Requires-Dist: exdrf-pd
|
|
19
|
+
Provides-Extra: dev
|
|
20
|
+
Requires-Dist: autoflake; extra == "dev"
|
|
21
|
+
Requires-Dist: black; extra == "dev"
|
|
22
|
+
Requires-Dist: build; extra == "dev"
|
|
23
|
+
Requires-Dist: flake8; extra == "dev"
|
|
24
|
+
Requires-Dist: isort; extra == "dev"
|
|
25
|
+
Requires-Dist: mypy; extra == "dev"
|
|
26
|
+
Requires-Dist: pre-commit; extra == "dev"
|
|
27
|
+
Requires-Dist: pyproject-flake8; extra == "dev"
|
|
28
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
29
|
+
Requires-Dist: pytest-mock; extra == "dev"
|
|
30
|
+
Requires-Dist: pytest; extra == "dev"
|
|
31
|
+
Requires-Dist: twine; extra == "dev"
|
|
32
|
+
Requires-Dist: wheel; extra == "dev"
|
|
33
|
+
Requires-Dist: click<8.2.0,>=8.1.8; extra == "dev"
|
|
34
|
+
|
|
35
|
+
# SqlAlchemy Support for Ex-DRF
|
|
36
|
+
|
|
37
|
+
The library provides guidance and support code for using SQLAlchemy with Ex-DRF.
|
|
38
|
+
|
|
39
|
+
## Usage
|
|
40
|
+
|
|
41
|
+
Start by basing your models off `Base` from `exdrf_al.base` module.
|
|
42
|
+
It is a rather simple class that allows for model andd fields
|
|
43
|
+
iteration. If you don't want to use it, take a look at the
|
|
44
|
+
implementation of that class for how to extract the information
|
|
45
|
+
you need from your models.
|
|
46
|
+
|
|
47
|
+
### Models
|
|
48
|
+
|
|
49
|
+
The library reads the description of models from the sqlAlchemy metadata. On top of that you cad add additional information by adding
|
|
50
|
+
members to the `info` key in the `__table_args__` model attribute.
|
|
51
|
+
|
|
52
|
+
The keys that are used inside the `info` dictionary are documented
|
|
53
|
+
in `exdrf.resource.ResExtraInfo`, which is the pydantic class that
|
|
54
|
+
parses the information. Here is brief description of the most
|
|
55
|
+
important keys:
|
|
56
|
+
|
|
57
|
+
- `label`: takes a string that is interpreted by the DSL in `exdrf.
|
|
58
|
+
label_dsl`; it is used to generate code that computes the label of
|
|
59
|
+
a record given the record. The `exdrf.label_dsl` module includes
|
|
60
|
+
code to create python and typescript code from a parsed
|
|
61
|
+
label definition.
|
|
62
|
+
|
|
63
|
+
Example:
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
class Example(Base):
|
|
67
|
+
__tablename__ = "the_table"
|
|
68
|
+
__table_args__ = {
|
|
69
|
+
"info": {
|
|
70
|
+
"label": """(if name name (concat "ID:" " id))""",
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
id: int
|
|
74
|
+
name: Optional[str] = None
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Fields
|
|
78
|
+
|
|
79
|
+
Just like with the models, the model field metadata is used to
|
|
80
|
+
extract the information. Additionally, we use values in the dictionary assigned to the `info` attribute to add additional information.
|
|
81
|
+
|
|
82
|
+
The keys that are used inside the `info` consist of a common subset
|
|
83
|
+
for all field types and specific keys for each field type. The common keys parsed by the `exdrf.field.FieldInfo` class are documented with
|
|
84
|
+
that class, and each field type is described in its own module under
|
|
85
|
+
`exdrf.field_types`.
|
|
86
|
+
|
|
87
|
+
Example:
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
class Example(Base):
|
|
91
|
+
__tablename__ = "the_table"
|
|
92
|
+
id: Mapped[int] = mapped_column(
|
|
93
|
+
primary_key=True,
|
|
94
|
+
doc="The unique identifier for a record within its table",
|
|
95
|
+
info={
|
|
96
|
+
"sortable": False
|
|
97
|
+
}
|
|
98
|
+
)
|
|
99
|
+
name: Mapped[Optional[str]] = mapped_column(
|
|
100
|
+
doc="The name of the record",
|
|
101
|
+
info={
|
|
102
|
+
"filterable": False,
|
|
103
|
+
"multiline": True,
|
|
104
|
+
"min_length": 3,
|
|
105
|
+
}
|
|
106
|
+
)
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Relationships
|
|
110
|
+
|
|
111
|
+
`relationship(..., info={...})` is validated with `exdrf.field_types.ref_base.RelExtraInfo`,
|
|
112
|
+
which extends `exdrf.field.FieldInfo`. Keys such as `direction` and `doc` are
|
|
113
|
+
required or conventional; optional keys from `FieldInfo` apply as well.
|
|
114
|
+
|
|
115
|
+
When `use_rel` is true on a **non-bridge** `OneToMany` relationship, Qt code
|
|
116
|
+
generation (`exdrf-gen-al2qt`) emits a dedicated editor tab with a
|
|
117
|
+
`DrfRelated`-style transfer list (`Qt{Parent}Rel{Ref}`) instead of an inline
|
|
118
|
+
`Qt{Ref}MuSe` control on category tabs.
|
|
119
|
+
|
|
120
|
+
Example:
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
items: Mapped[Set["Item"]] = relationship(
|
|
124
|
+
"Item",
|
|
125
|
+
back_populates="owner",
|
|
126
|
+
collection_class=set,
|
|
127
|
+
info={
|
|
128
|
+
"doc": "Owned items",
|
|
129
|
+
"direction": "OneToMany",
|
|
130
|
+
"use_rel": True,
|
|
131
|
+
},
|
|
132
|
+
)
|
|
133
|
+
```
|
exdrf_al-0.1.8/README.md
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# SqlAlchemy Support for Ex-DRF
|
|
2
|
+
|
|
3
|
+
The library provides guidance and support code for using SQLAlchemy with Ex-DRF.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
Start by basing your models off `Base` from `exdrf_al.base` module.
|
|
8
|
+
It is a rather simple class that allows for model andd fields
|
|
9
|
+
iteration. If you don't want to use it, take a look at the
|
|
10
|
+
implementation of that class for how to extract the information
|
|
11
|
+
you need from your models.
|
|
12
|
+
|
|
13
|
+
### Models
|
|
14
|
+
|
|
15
|
+
The library reads the description of models from the sqlAlchemy metadata. On top of that you cad add additional information by adding
|
|
16
|
+
members to the `info` key in the `__table_args__` model attribute.
|
|
17
|
+
|
|
18
|
+
The keys that are used inside the `info` dictionary are documented
|
|
19
|
+
in `exdrf.resource.ResExtraInfo`, which is the pydantic class that
|
|
20
|
+
parses the information. Here is brief description of the most
|
|
21
|
+
important keys:
|
|
22
|
+
|
|
23
|
+
- `label`: takes a string that is interpreted by the DSL in `exdrf.
|
|
24
|
+
label_dsl`; it is used to generate code that computes the label of
|
|
25
|
+
a record given the record. The `exdrf.label_dsl` module includes
|
|
26
|
+
code to create python and typescript code from a parsed
|
|
27
|
+
label definition.
|
|
28
|
+
|
|
29
|
+
Example:
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
class Example(Base):
|
|
33
|
+
__tablename__ = "the_table"
|
|
34
|
+
__table_args__ = {
|
|
35
|
+
"info": {
|
|
36
|
+
"label": """(if name name (concat "ID:" " id))""",
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
id: int
|
|
40
|
+
name: Optional[str] = None
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Fields
|
|
44
|
+
|
|
45
|
+
Just like with the models, the model field metadata is used to
|
|
46
|
+
extract the information. Additionally, we use values in the dictionary assigned to the `info` attribute to add additional information.
|
|
47
|
+
|
|
48
|
+
The keys that are used inside the `info` consist of a common subset
|
|
49
|
+
for all field types and specific keys for each field type. The common keys parsed by the `exdrf.field.FieldInfo` class are documented with
|
|
50
|
+
that class, and each field type is described in its own module under
|
|
51
|
+
`exdrf.field_types`.
|
|
52
|
+
|
|
53
|
+
Example:
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
class Example(Base):
|
|
57
|
+
__tablename__ = "the_table"
|
|
58
|
+
id: Mapped[int] = mapped_column(
|
|
59
|
+
primary_key=True,
|
|
60
|
+
doc="The unique identifier for a record within its table",
|
|
61
|
+
info={
|
|
62
|
+
"sortable": False
|
|
63
|
+
}
|
|
64
|
+
)
|
|
65
|
+
name: Mapped[Optional[str]] = mapped_column(
|
|
66
|
+
doc="The name of the record",
|
|
67
|
+
info={
|
|
68
|
+
"filterable": False,
|
|
69
|
+
"multiline": True,
|
|
70
|
+
"min_length": 3,
|
|
71
|
+
}
|
|
72
|
+
)
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Relationships
|
|
76
|
+
|
|
77
|
+
`relationship(..., info={...})` is validated with `exdrf.field_types.ref_base.RelExtraInfo`,
|
|
78
|
+
which extends `exdrf.field.FieldInfo`. Keys such as `direction` and `doc` are
|
|
79
|
+
required or conventional; optional keys from `FieldInfo` apply as well.
|
|
80
|
+
|
|
81
|
+
When `use_rel` is true on a **non-bridge** `OneToMany` relationship, Qt code
|
|
82
|
+
generation (`exdrf-gen-al2qt`) emits a dedicated editor tab with a
|
|
83
|
+
`DrfRelated`-style transfer list (`Qt{Parent}Rel{Ref}`) instead of an inline
|
|
84
|
+
`Qt{Ref}MuSe` control on category tabs.
|
|
85
|
+
|
|
86
|
+
Example:
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
items: Mapped[Set["Item"]] = relationship(
|
|
90
|
+
"Item",
|
|
91
|
+
back_populates="owner",
|
|
92
|
+
collection_class=set,
|
|
93
|
+
info={
|
|
94
|
+
"doc": "Owned items",
|
|
95
|
+
"direction": "OneToMany",
|
|
96
|
+
"use_rel": True,
|
|
97
|
+
},
|
|
98
|
+
)
|
|
99
|
+
```
|
|
File without changes
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# file generated by vcs-versioning
|
|
2
|
+
# don't change, don't track in version control
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
__all__ = [
|
|
6
|
+
"__version__",
|
|
7
|
+
"__version_tuple__",
|
|
8
|
+
"version",
|
|
9
|
+
"version_tuple",
|
|
10
|
+
"__commit_id__",
|
|
11
|
+
"commit_id",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
version: str
|
|
15
|
+
__version__: str
|
|
16
|
+
__version_tuple__: tuple[int | str, ...]
|
|
17
|
+
version_tuple: tuple[int | str, ...]
|
|
18
|
+
commit_id: str | None
|
|
19
|
+
__commit_id__: str | None
|
|
20
|
+
|
|
21
|
+
__version__ = version = '0.1.8'
|
|
22
|
+
__version_tuple__ = version_tuple = (0, 1, 8)
|
|
23
|
+
|
|
24
|
+
__commit_id__ = commit_id = 'g450ddaecd'
|