hapi-schema 0.1.1__tar.gz → 0.2.0__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.
Files changed (30) hide show
  1. {hapi_schema-0.1.1 → hapi_schema-0.2.0}/.config/pre-commit-config.yaml +1 -1
  2. {hapi_schema-0.1.1 → hapi_schema-0.2.0}/.gitignore +3 -7
  3. {hapi_schema-0.1.1 → hapi_schema-0.2.0}/PKG-INFO +3 -2
  4. {hapi_schema-0.1.1 → hapi_schema-0.2.0}/changelog.md +7 -0
  5. {hapi_schema-0.1.1 → hapi_schema-0.2.0}/pyproject.toml +4 -4
  6. {hapi_schema-0.1.1 → hapi_schema-0.2.0}/requirements.txt +2 -2
  7. {hapi_schema-0.1.1 → hapi_schema-0.2.0}/src/hapi_schema/_version.py +2 -2
  8. {hapi_schema-0.1.1 → hapi_schema-0.2.0}/src/hapi_schema/db_admin1.py +3 -3
  9. {hapi_schema-0.1.1 → hapi_schema-0.2.0}/src/hapi_schema/db_admin2.py +3 -3
  10. {hapi_schema-0.1.1 → hapi_schema-0.2.0}/src/hapi_schema/db_age_range.py +4 -3
  11. {hapi_schema-0.1.1 → hapi_schema-0.2.0}/src/hapi_schema/db_dataset.py +4 -3
  12. {hapi_schema-0.1.1 → hapi_schema-0.2.0}/src/hapi_schema/db_gender.py +4 -3
  13. {hapi_schema-0.1.1 → hapi_schema-0.2.0}/src/hapi_schema/db_location.py +4 -3
  14. {hapi_schema-0.1.1 → hapi_schema-0.2.0}/src/hapi_schema/db_operational_presence.py +3 -3
  15. {hapi_schema-0.1.1 → hapi_schema-0.2.0}/src/hapi_schema/db_org.py +3 -3
  16. {hapi_schema-0.1.1 → hapi_schema-0.2.0}/src/hapi_schema/db_org_type.py +4 -3
  17. {hapi_schema-0.1.1 → hapi_schema-0.2.0}/src/hapi_schema/db_population.py +3 -3
  18. {hapi_schema-0.1.1 → hapi_schema-0.2.0}/src/hapi_schema/db_resource.py +3 -3
  19. {hapi_schema-0.1.1 → hapi_schema-0.2.0}/src/hapi_schema/db_sector.py +4 -3
  20. hapi_schema-0.2.0/src/hapi_schema/utils/__init__.py +0 -0
  21. hapi_schema-0.2.0/src/hapi_schema/utils/base.py +8 -0
  22. hapi_schema-0.2.0/src/hapi_schema/utils/view_params.py +13 -0
  23. hapi_schema-0.1.1/src/hapi_schema/db_orgtype.py +0 -20
  24. {hapi_schema-0.1.1 → hapi_schema-0.2.0}/.config/black.toml +0 -0
  25. {hapi_schema-0.1.1 → hapi_schema-0.2.0}/.config/ruff.toml +0 -0
  26. {hapi_schema-0.1.1 → hapi_schema-0.2.0}/.github/workflows/publish.yaml +0 -0
  27. {hapi_schema-0.1.1 → hapi_schema-0.2.0}/LICENSE +0 -0
  28. {hapi_schema-0.1.1 → hapi_schema-0.2.0}/README.md +0 -0
  29. {hapi_schema-0.1.1 → hapi_schema-0.2.0}/contributing.md +0 -0
  30. {hapi_schema-0.1.1 → hapi_schema-0.2.0}/src/hapi_schema/__init__.py +0 -0
@@ -23,4 +23,4 @@ repos:
23
23
  - id: pip-compile
24
24
  name: pip-compile requirements.txt
25
25
  files: pyproject.toml
26
- args: [pyproject.toml, --resolver=backtracking, --upgrade, -q, -o, requirements.txt]
26
+ args: [pyproject.toml, --resolver=backtracking, --all-extras, --upgrade, -q, -o, requirements.txt]
@@ -161,13 +161,9 @@ cython_debug/
161
161
  .idea/
162
162
 
163
163
  ## Project
164
- # DB
165
- hapi.db
166
- # Version file
167
- src/hapi/pipelines/_version.py
168
164
 
169
- # Project YAML file
170
- src/hapi/pipelines/app/project_configuration.yaml
165
+ # Version file
166
+ src/hapi_schema/_version.py
171
167
 
172
- #OS Files
168
+ # OS Files
173
169
  *DS_Store
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hapi-schema
3
- Version: 0.1.1
3
+ Version: 0.2.0
4
4
  Summary: HAPI database schema specified in SQLAlchemy
5
5
  Project-URL: Homepage, https://github.com/OCHA-DAP/hapi-schemas
6
6
  Author-email: Simon Johnson <simon.johnson@un.org>
@@ -24,8 +24,9 @@ Classifier: Programming Language :: Python :: 3.11
24
24
  Classifier: Programming Language :: Python :: 3.12
25
25
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
26
26
  Requires-Python: >=3.8
27
- Requires-Dist: hdx-python-database
28
27
  Requires-Dist: sqlalchemy
28
+ Provides-Extra: database
29
+ Requires-Dist: hdx-python-database>=1.2.8; extra == 'database'
29
30
  Description-Content-Type: text/markdown
30
31
 
31
32
  # hapi-sqlalchemy-schema
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.2.0]
9
+
10
+ ### Changed
11
+
12
+ - Dependency on hdx-python-database is optional
13
+ - View definitions converted to parameter dicts
14
+
8
15
  ## [0.1.1]
9
16
 
10
17
  ### Fixed
@@ -31,10 +31,7 @@ classifiers = [
31
31
  "Operating System :: Microsoft :: Windows",
32
32
  ]
33
33
  requires-python = ">=3.8"
34
- dependencies = [
35
- 'sqlalchemy',
36
- 'hdx-python-database'
37
- ]
34
+ dependencies = ['sqlalchemy']
38
35
  dynamic = ["version"]
39
36
 
40
37
  [project.readme]
@@ -44,6 +41,9 @@ content-type = "text/markdown"
44
41
  [project.urls]
45
42
  Homepage = "https://github.com/OCHA-DAP/hapi-schemas"
46
43
 
44
+ [project.optional-dependencies]
45
+ database = ["hdx-python-database>=1.2.8"]
46
+
47
47
  #########
48
48
  # Hatch #
49
49
  #########
@@ -2,13 +2,13 @@
2
2
  # This file is autogenerated by pip-compile with Python 3.11
3
3
  # by the following command:
4
4
  #
5
- # pip-compile --output-file=requirements.txt pyproject.toml
5
+ # pip-compile --all-extras --output-file=requirements.txt pyproject.toml
6
6
  #
7
7
  greenlet==3.0.0
8
8
  # via sqlalchemy
9
9
  hdx-python-database==1.2.8
10
10
  # via hapi-schema (pyproject.toml)
11
- sqlalchemy==2.0.21
11
+ sqlalchemy==2.0.22
12
12
  # via
13
13
  # hapi-schema (pyproject.toml)
14
14
  # hdx-python-database
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '0.1.1'
16
- __version_tuple__ = version_tuple = (0, 1, 1)
15
+ __version__ = version = '0.2.0'
16
+ __version_tuple__ = version_tuple = (0, 2, 0)
@@ -1,8 +1,6 @@
1
1
  """Admin1 table and view."""
2
2
  from datetime import datetime
3
3
 
4
- from hdx.database.no_timezone import Base
5
- from hdx.database.views import view
6
4
  from sqlalchemy import (
7
5
  Boolean,
8
6
  DateTime,
@@ -15,6 +13,8 @@ from sqlalchemy import (
15
13
  from sqlalchemy.orm import Mapped, mapped_column, relationship
16
14
 
17
15
  from hapi_schema.db_location import DBLocation
16
+ from hapi_schema.utils.base import Base
17
+ from hapi_schema.utils.view_params import ViewParams
18
18
 
19
19
 
20
20
  class DBAdmin1(Base):
@@ -40,7 +40,7 @@ class DBAdmin1(Base):
40
40
  location = relationship("DBLocation")
41
41
 
42
42
 
43
- admin1_view = view(
43
+ view_params_admin1 = ViewParams(
44
44
  name="admin1_view",
45
45
  metadata=Base.metadata,
46
46
  selectable=select(
@@ -1,8 +1,6 @@
1
1
  """Admin2 table and view."""
2
2
  from datetime import datetime
3
3
 
4
- from hdx.database.no_timezone import Base
5
- from hdx.database.views import view
6
4
  from sqlalchemy import (
7
5
  Boolean,
8
6
  DateTime,
@@ -16,6 +14,8 @@ from sqlalchemy.orm import Mapped, mapped_column, relationship
16
14
 
17
15
  from hapi_schema.db_admin1 import DBAdmin1
18
16
  from hapi_schema.db_location import DBLocation
17
+ from hapi_schema.utils.base import Base
18
+ from hapi_schema.utils.view_params import ViewParams
19
19
 
20
20
 
21
21
  class DBAdmin2(Base):
@@ -41,7 +41,7 @@ class DBAdmin2(Base):
41
41
  admin1 = relationship("DBAdmin1")
42
42
 
43
43
 
44
- admin2_view = view(
44
+ view_params_admin2 = ViewParams(
45
45
  name="admin2_view",
46
46
  metadata=Base.metadata,
47
47
  selectable=select(
@@ -1,10 +1,11 @@
1
1
  """Age range table and view."""
2
2
 
3
- from hdx.database.no_timezone import Base
4
- from hdx.database.views import view
5
3
  from sqlalchemy import Integer, String, select
6
4
  from sqlalchemy.orm import Mapped, mapped_column
7
5
 
6
+ from hapi_schema.utils.base import Base
7
+ from hapi_schema.utils.view_params import ViewParams
8
+
8
9
 
9
10
  class DBAgeRange(Base):
10
11
  __tablename__ = "age_range"
@@ -14,7 +15,7 @@ class DBAgeRange(Base):
14
15
  age_max: Mapped[int] = mapped_column(Integer, nullable=True)
15
16
 
16
17
 
17
- age_range_view = view(
18
+ view_params_age_range = ViewParams(
18
19
  name="age_range_view",
19
20
  metadata=Base.metadata,
20
21
  selectable=select(*DBAgeRange.__table__.columns),
@@ -1,10 +1,11 @@
1
1
  """Dataset table and view."""
2
2
 
3
- from hdx.database.no_timezone import Base
4
- from hdx.database.views import view
5
3
  from sqlalchemy import Integer, String, select
6
4
  from sqlalchemy.orm import Mapped, mapped_column
7
5
 
6
+ from hapi_schema.utils.base import Base
7
+ from hapi_schema.utils.view_params import ViewParams
8
+
8
9
 
9
10
  class DBDataset(Base):
10
11
  __tablename__ = "dataset"
@@ -25,7 +26,7 @@ class DBDataset(Base):
25
26
  )
26
27
 
27
28
 
28
- dataset_view = view(
29
+ view_params_dataset = ViewParams(
29
30
  name="dataset_view",
30
31
  metadata=Base.metadata,
31
32
  selectable=select(*DBDataset.__table__.columns),
@@ -1,10 +1,11 @@
1
1
  """Gender table and view."""
2
2
 
3
- from hdx.database.no_timezone import Base
4
- from hdx.database.views import view
5
3
  from sqlalchemy import CHAR, String, select
6
4
  from sqlalchemy.orm import Mapped, mapped_column
7
5
 
6
+ from hapi_schema.utils.base import Base
7
+ from hapi_schema.utils.view_params import ViewParams
8
+
8
9
 
9
10
  class DBGender(Base):
10
11
  __tablename__ = "gender"
@@ -13,7 +14,7 @@ class DBGender(Base):
13
14
  description: Mapped[str] = mapped_column(String(256), nullable=False)
14
15
 
15
16
 
16
- gender_view = view(
17
+ view_params_gender = ViewParams(
17
18
  name="gender_view",
18
19
  metadata=Base.metadata,
19
20
  selectable=select(*DBGender.__table__.columns),
@@ -1,11 +1,12 @@
1
1
  """Location table and view."""
2
2
  from datetime import datetime
3
3
 
4
- from hdx.database.no_timezone import Base
5
- from hdx.database.views import view
6
4
  from sqlalchemy import DateTime, Integer, String, select, text
7
5
  from sqlalchemy.orm import Mapped, mapped_column
8
6
 
7
+ from hapi_schema.utils.base import Base
8
+ from hapi_schema.utils.view_params import ViewParams
9
+
9
10
 
10
11
  class DBLocation(Base):
11
12
  __tablename__ = "location"
@@ -21,7 +22,7 @@ class DBLocation(Base):
21
22
  )
22
23
 
23
24
 
24
- location_view = view(
25
+ view_params_location = ViewParams(
25
26
  name="location_view",
26
27
  metadata=Base.metadata,
27
28
  selectable=select(*DBLocation.__table__.columns),
@@ -1,8 +1,6 @@
1
1
  """OperationalPresence table and view."""
2
2
  from datetime import datetime
3
3
 
4
- from hdx.database.no_timezone import Base
5
- from hdx.database.views import view
6
4
  from sqlalchemy import (
7
5
  DateTime,
8
6
  ForeignKey,
@@ -21,6 +19,8 @@ from hapi_schema.db_org import DBOrg
21
19
  from hapi_schema.db_org_type import DBOrgType
22
20
  from hapi_schema.db_resource import DBResource
23
21
  from hapi_schema.db_sector import DBSector
22
+ from hapi_schema.utils.base import Base
23
+ from hapi_schema.utils.view_params import ViewParams
24
24
 
25
25
 
26
26
  class DBOperationalPresence(Base):
@@ -54,7 +54,7 @@ class DBOperationalPresence(Base):
54
54
  admin2 = relationship("DBAdmin2")
55
55
 
56
56
 
57
- operational_presence_view = view(
57
+ view_params_operational_presence = ViewParams(
58
58
  name="operational_presence_view",
59
59
  metadata=Base.metadata,
60
60
  selectable=select(
@@ -1,8 +1,6 @@
1
1
  """Org table and view."""
2
2
  from datetime import datetime
3
3
 
4
- from hdx.database.no_timezone import Base
5
- from hdx.database.views import view
6
4
  from sqlalchemy import (
7
5
  DateTime,
8
6
  ForeignKey,
@@ -14,6 +12,8 @@ from sqlalchemy import (
14
12
  from sqlalchemy.orm import Mapped, mapped_column, relationship
15
13
 
16
14
  from hapi_schema.db_org_type import DBOrgType
15
+ from hapi_schema.utils.base import Base
16
+ from hapi_schema.utils.view_params import ViewParams
17
17
 
18
18
 
19
19
  class DBOrg(Base):
@@ -36,7 +36,7 @@ class DBOrg(Base):
36
36
  org_type = relationship("DBOrgType")
37
37
 
38
38
 
39
- org_view = view(
39
+ view_params_org = ViewParams(
40
40
  name="org_view",
41
41
  metadata=Base.metadata,
42
42
  selectable=select(
@@ -1,10 +1,11 @@
1
1
  """OrgType table and view."""
2
2
 
3
- from hdx.database.no_timezone import Base
4
- from hdx.database.views import view
5
3
  from sqlalchemy import String, select
6
4
  from sqlalchemy.orm import Mapped, mapped_column
7
5
 
6
+ from hapi_schema.utils.base import Base
7
+ from hapi_schema.utils.view_params import ViewParams
8
+
8
9
 
9
10
  class DBOrgType(Base):
10
11
  __tablename__ = "org_type"
@@ -13,7 +14,7 @@ class DBOrgType(Base):
13
14
  description: Mapped[str] = mapped_column(String(512), nullable=False)
14
15
 
15
16
 
16
- org_type_view = view(
17
+ view_params_org_type = ViewParams(
17
18
  name="org_type_view",
18
19
  metadata=Base.metadata,
19
20
  selectable=select(*DBOrgType.__table__.columns),
@@ -1,8 +1,6 @@
1
1
  """Population table and view."""
2
2
  from datetime import datetime
3
3
 
4
- from hdx.database.no_timezone import Base
5
- from hdx.database.views import view
6
4
  from sqlalchemy import (
7
5
  DateTime,
8
6
  ForeignKey,
@@ -20,6 +18,8 @@ from hapi_schema.db_dataset import DBDataset
20
18
  from hapi_schema.db_gender import DBGender
21
19
  from hapi_schema.db_location import DBLocation
22
20
  from hapi_schema.db_resource import DBResource
21
+ from hapi_schema.utils.base import Base
22
+ from hapi_schema.utils.view_params import ViewParams
23
23
 
24
24
 
25
25
  class DBPopulation(Base):
@@ -56,7 +56,7 @@ class DBPopulation(Base):
56
56
  gender = relationship("DBGender")
57
57
 
58
58
 
59
- population_view = view(
59
+ view_params_population = ViewParams(
60
60
  name="population_view",
61
61
  metadata=Base.metadata,
62
62
  selectable=select(
@@ -1,7 +1,5 @@
1
1
  """Resource table and view."""
2
2
 
3
- from hdx.database.no_timezone import Base
4
- from hdx.database.views import view
5
3
  from sqlalchemy import (
6
4
  Boolean,
7
5
  DateTime,
@@ -13,6 +11,8 @@ from sqlalchemy import (
13
11
  from sqlalchemy.orm import Mapped, mapped_column, relationship
14
12
 
15
13
  from hapi_schema.db_dataset import DBDataset
14
+ from hapi_schema.utils.base import Base
15
+ from hapi_schema.utils.view_params import ViewParams
16
16
 
17
17
 
18
18
  class DBResource(Base):
@@ -37,7 +37,7 @@ class DBResource(Base):
37
37
  dataset = relationship("DBDataset")
38
38
 
39
39
 
40
- resource_view = view(
40
+ view_params_resource = ViewParams(
41
41
  name="resource_view",
42
42
  metadata=Base.metadata,
43
43
  selectable=select(
@@ -1,11 +1,12 @@
1
1
  """Sector table and view."""
2
2
  from datetime import datetime
3
3
 
4
- from hdx.database.no_timezone import Base
5
- from hdx.database.views import view
6
4
  from sqlalchemy import DateTime, String, select, text
7
5
  from sqlalchemy.orm import Mapped, mapped_column
8
6
 
7
+ from hapi_schema.utils.base import Base
8
+ from hapi_schema.utils.view_params import ViewParams
9
+
9
10
 
10
11
  class DBSector(Base):
11
12
  __tablename__ = "sector"
@@ -20,7 +21,7 @@ class DBSector(Base):
20
21
  )
21
22
 
22
23
 
23
- sector_view = view(
24
+ view_params_sector = ViewParams(
24
25
  name="sector_view",
25
26
  metadata=Base.metadata,
26
27
  selectable=select(*DBSector.__table__.columns),
File without changes
@@ -0,0 +1,8 @@
1
+ try:
2
+ from hdx.database.no_timezone import Base
3
+
4
+ except ImportError:
5
+ from sqlalchemy.orm import DeclarativeBase
6
+
7
+ class Base(DeclarativeBase):
8
+ pass
@@ -0,0 +1,13 @@
1
+ from dataclasses import dataclass
2
+
3
+ from sqlalchemy.orm import DeclarativeMeta
4
+ from sqlalchemy.sql.expression import Selectable
5
+
6
+
7
+ @dataclass
8
+ class ViewParams:
9
+ """Class for keeping view constructor parameters."""
10
+
11
+ name: str
12
+ metadata: DeclarativeMeta
13
+ selectable: Selectable
@@ -1,20 +0,0 @@
1
- """OrgType table and view."""
2
-
3
- from hdx.database.no_timezone import Base
4
- from hdx.database.views import view
5
- from sqlalchemy import String, select
6
- from sqlalchemy.orm import Mapped, mapped_column
7
-
8
-
9
- class DBOrgType(Base):
10
- __tablename__ = "org_type"
11
-
12
- code: Mapped[str] = mapped_column(String(32), primary_key=True)
13
- description: Mapped[str] = mapped_column(String(512), nullable=False)
14
-
15
-
16
- org_type_view = view(
17
- name="org_type_view",
18
- metadata=Base.metadata,
19
- selectable=select(*DBOrgType.__table__.columns),
20
- )
File without changes
File without changes
File without changes