maleo-foundation 0.0.61__py3-none-any.whl → 0.0.63__py3-none-any.whl
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.
- maleo_foundation/db/__init__.py +3 -2
- maleo_foundation/db/manager.py +14 -0
- maleo_foundation/db/table.py +29 -0
- {maleo_foundation-0.0.61.dist-info → maleo_foundation-0.0.63.dist-info}/METADATA +1 -1
- {maleo_foundation-0.0.61.dist-info → maleo_foundation-0.0.63.dist-info}/RECORD +7 -6
- maleo_foundation/db/database.py +0 -41
- {maleo_foundation-0.0.61.dist-info → maleo_foundation-0.0.63.dist-info}/WHEEL +0 -0
- {maleo_foundation-0.0.61.dist-info → maleo_foundation-0.0.63.dist-info}/top_level.txt +0 -0
maleo_foundation/db/__init__.py
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from sqlalchemy import Engine, MetaData
|
|
2
|
+
from sqlalchemy.ext.declarative import DeclarativeMeta
|
|
3
|
+
from sqlalchemy.orm import declarative_base
|
|
4
|
+
|
|
5
|
+
class DatabaseManager:
|
|
6
|
+
Base:DeclarativeMeta = declarative_base() #* Correct way to define a declarative base
|
|
7
|
+
|
|
8
|
+
#* Explicitly define the type of metadata
|
|
9
|
+
metadata:MetaData = Base.metadata
|
|
10
|
+
|
|
11
|
+
@classmethod
|
|
12
|
+
def initialize(cls, engine:Engine):
|
|
13
|
+
"""Creates the database tables if they do not exist."""
|
|
14
|
+
cls.metadata.create_all(engine)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from sqlalchemy import Column, Integer, UUID, TIMESTAMP, Enum, func
|
|
2
|
+
from sqlalchemy.orm import declared_attr
|
|
3
|
+
from uuid import uuid4
|
|
4
|
+
from maleo_foundation.enums import BaseEnums
|
|
5
|
+
from maleo_foundation.utils.formatter.case import CaseFormatter
|
|
6
|
+
|
|
7
|
+
class BaseTable:
|
|
8
|
+
__abstract__ = True
|
|
9
|
+
|
|
10
|
+
@declared_attr
|
|
11
|
+
def __tablename__(cls) -> str:
|
|
12
|
+
return CaseFormatter.to_snake_case(cls.__name__)
|
|
13
|
+
|
|
14
|
+
#* ----- ----- Common columns definition ----- ----- *#
|
|
15
|
+
|
|
16
|
+
#* Identifiers
|
|
17
|
+
id = Column(Integer, primary_key=True)
|
|
18
|
+
uuid = Column(UUID, default=uuid4, unique=True, nullable=False)
|
|
19
|
+
|
|
20
|
+
#* Timestamps
|
|
21
|
+
created_at = Column(TIMESTAMP(timezone=True), server_default=func.now(), nullable=False)
|
|
22
|
+
updated_at = Column(TIMESTAMP(timezone=True), server_default=func.now(), onupdate=func.now(), nullable=False)
|
|
23
|
+
deleted_at = Column(TIMESTAMP(timezone=True))
|
|
24
|
+
restored_at = Column(TIMESTAMP(timezone=True))
|
|
25
|
+
deactivated_at = Column(TIMESTAMP(timezone=True))
|
|
26
|
+
activated_at = Column(TIMESTAMP(timezone=True), server_default=func.now(), nullable=False)
|
|
27
|
+
|
|
28
|
+
#* Statuses
|
|
29
|
+
status = Column(Enum(BaseEnums.StatusType, name="statustype"), default=BaseEnums.StatusType.ACTIVE, nullable=False)
|
|
@@ -13,10 +13,11 @@ maleo_foundation/clients/google/cloud/secret.py,sha256=cFewA-EYsAaEfxc2G2XGzwHre
|
|
|
13
13
|
maleo_foundation/clients/google/cloud/storage.py,sha256=y_HAsbcGSnu5sxZPxaQWFWvOlF3vEcqkej2834OgAS0,2617
|
|
14
14
|
maleo_foundation/clients/utils/__init__.py,sha256=hChEGABHH4tOFxPRcpxmlhkM9PgF18M7wXapH88hpu4,131
|
|
15
15
|
maleo_foundation/clients/utils/logger.py,sha256=QhxljzrvNY_gXAHCqaOUJJAgwvvcE9v3IQK6AWYxzM4,1144
|
|
16
|
-
maleo_foundation/db/__init__.py,sha256=
|
|
17
|
-
maleo_foundation/db/database.py,sha256=6i-KLR4WCS1mYThGVr_xwZhAKgzflPii0PITEUZlu6c,1724
|
|
16
|
+
maleo_foundation/db/__init__.py,sha256=fmvhCz4_siHfyKJujcUakKDKmuLxMhxn2w5tmfQwfcM,135
|
|
18
17
|
maleo_foundation/db/engine.py,sha256=kw2SMMiWy5KARquh4TLk7v6HwlHW97lUIUvqdFbhNxk,1600
|
|
18
|
+
maleo_foundation/db/manager.py,sha256=czs-6czNvKHZ7zWRX1nPpKJcdsadyX8R2DnZlA_6mlk,500
|
|
19
19
|
maleo_foundation/db/session.py,sha256=tI13DJ6rLo8FOpSIFZrmD4dbuxY_c0RTjwEGb76ZOo0,2681
|
|
20
|
+
maleo_foundation/db/table.py,sha256=Dk5GXeO0gbBBPN2PJtZhlUx2x3vMbT4dxTBc3YLBbuc,1199
|
|
20
21
|
maleo_foundation/expanded_types/__init__.py,sha256=RohoIQCiMvo2g6Jacq2dlqNXg3WLmRc-TD8nvMsyDKs,275
|
|
21
22
|
maleo_foundation/expanded_types/client.py,sha256=To0kRXp3QTmuSu5rWKaCiTsMK9qkYiyYKYbHfw-y1fY,2396
|
|
22
23
|
maleo_foundation/expanded_types/query.py,sha256=0yUG-JIVsanzB7KAkrRz_OsrhP6J0bRqD9Q3l3atQnk,2384
|
|
@@ -52,7 +53,7 @@ maleo_foundation/utils/logger.py,sha256=978P57JOhGR-WIu7xdPXBIwd3JrfLLA8WerVzxhE
|
|
|
52
53
|
maleo_foundation/utils/query.py,sha256=ODQ3adOYQNj5E2cRW9ytbjBz56nEDcnfq8mQ6YZbCCM,4375
|
|
53
54
|
maleo_foundation/utils/formatter/__init__.py,sha256=iKf5YCbEdg1qKnFHyKqqcQbqAqEeRUf8mhI3v3dQoj8,78
|
|
54
55
|
maleo_foundation/utils/formatter/case.py,sha256=TmvvlfzGdC_omMTB5vAa40TZBxQ3hnr-SYeo0M52Rlg,1352
|
|
55
|
-
maleo_foundation-0.0.
|
|
56
|
-
maleo_foundation-0.0.
|
|
57
|
-
maleo_foundation-0.0.
|
|
58
|
-
maleo_foundation-0.0.
|
|
56
|
+
maleo_foundation-0.0.63.dist-info/METADATA,sha256=sxAnHtZaM6BoM1sjBHXP9cu1rxkBrWktAHtwN7Kx5wU,3160
|
|
57
|
+
maleo_foundation-0.0.63.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
|
|
58
|
+
maleo_foundation-0.0.63.dist-info/top_level.txt,sha256=_iBos3F_bhEOdjOnzeiEYSrCucasc810xXtLBXI8cQc,17
|
|
59
|
+
maleo_foundation-0.0.63.dist-info/RECORD,,
|
maleo_foundation/db/database.py
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
from sqlalchemy import Engine, MetaData, Column, Integer, UUID, TIMESTAMP, Enum, func
|
|
2
|
-
from sqlalchemy.ext.declarative import DeclarativeMeta
|
|
3
|
-
from sqlalchemy.orm import declarative_base, declared_attr
|
|
4
|
-
from uuid import uuid4
|
|
5
|
-
from maleo_foundation.enums import BaseEnums
|
|
6
|
-
from maleo_foundation.utils.formatter.case import CaseFormatter
|
|
7
|
-
|
|
8
|
-
class DatabaseManager:
|
|
9
|
-
class BaseMixin:
|
|
10
|
-
__abstract__ = True
|
|
11
|
-
|
|
12
|
-
@declared_attr
|
|
13
|
-
def __tablename__(cls) -> str:
|
|
14
|
-
return CaseFormatter.to_snake_case(cls.__name__)
|
|
15
|
-
|
|
16
|
-
#* ----- ----- Common columns definition ----- ----- *#
|
|
17
|
-
|
|
18
|
-
#* Identifiers
|
|
19
|
-
id = Column(Integer, primary_key=True)
|
|
20
|
-
uuid = Column(UUID, default=uuid4, unique=True, nullable=False)
|
|
21
|
-
|
|
22
|
-
#* Timestamps
|
|
23
|
-
created_at = Column(TIMESTAMP(timezone=True), server_default=func.now(), nullable=False)
|
|
24
|
-
updated_at = Column(TIMESTAMP(timezone=True), server_default=func.now(), onupdate=func.now(), nullable=False)
|
|
25
|
-
deleted_at = Column(TIMESTAMP(timezone=True))
|
|
26
|
-
restored_at = Column(TIMESTAMP(timezone=True))
|
|
27
|
-
deactivated_at = Column(TIMESTAMP(timezone=True))
|
|
28
|
-
activated_at = Column(TIMESTAMP(timezone=True), server_default=func.now(), nullable=False)
|
|
29
|
-
|
|
30
|
-
#* Statuses
|
|
31
|
-
status = Column(Enum(BaseEnums.StatusType, name="statustype"), default=BaseEnums.StatusType.ACTIVE, nullable=False)
|
|
32
|
-
|
|
33
|
-
Base:DeclarativeMeta = declarative_base() #* Correct way to define a declarative base
|
|
34
|
-
|
|
35
|
-
#* Explicitly define the type of metadata
|
|
36
|
-
metadata:MetaData = Base.metadata
|
|
37
|
-
|
|
38
|
-
@classmethod
|
|
39
|
-
def initialize(cls, engine:Engine):
|
|
40
|
-
"""Creates the database tables if they do not exist."""
|
|
41
|
-
cls.metadata.create_all(engine)
|
|
File without changes
|
|
File without changes
|