DefPixel 0.1.4__75-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.
- DefPixel/DataAccessObject/Configuration.py +15 -0
- DefPixel/DataAccessObject/Connection.py +25 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Adapters/Array.py +16 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Adapters/JavaScriptObjectNotation.py +74 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Adapters/__init__.py +51 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Column.py +34 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Compiler.py +161 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Configuration.py +116 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Connection.py +138 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Constraint.py +18 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Constraints/Check.py +23 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Constraints/Columns.py +24 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Constraints/ForeignKey.py +56 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Constraints/PrimaryKey.py +21 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Constraints/Unique.py +25 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Constraints/__init__.py +13 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Context.py +48 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Cursor.py +123 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Executors/Create.py +181 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Executors/Delete.py +31 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Executors/Drop.py +53 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Executors/Get.py +24 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Executors/Insert.py +98 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Executors/Query.py +37 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Executors/Select.py +122 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Executors/Update.py +57 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Executors/__init__.py +19 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Expr.py +11 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Exprs/Common.py +180 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Exprs/Compare.py +87 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Exprs/Condition.py +155 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Exprs/JavaScriptObjectNotation.py +53 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Exprs/Operator.py +42 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Exprs/String.py +48 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Exprs/__init__.py +75 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Function.py +11 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Functions/Common.py +142 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Functions/DateTime.py +219 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Functions/JavaScriptObjectNotation.py +100 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Functions/Sequence.py +55 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Functions/__init__.py +91 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Index.py +135 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Joins/FullOuter.py +15 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Joins/Inner.py +15 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Joins/Join.py +41 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Joins/LeftOuter.py +15 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Joins/RightOuter.py +15 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Joins/__init__.py +15 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Mapping.py +359 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Orders.py +59 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Pool.py +84 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Schema.py +28 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Sequence.py +55 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Session.py +84 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Type.py +113 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Types/Array.py +61 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Types/Binary.py +34 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Types/Bool.py +29 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Types/DateTime.py +120 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Types/JavaScriptObjectNotation.py +52 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Types/Numeric.py +151 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Types/Size.py +13 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Types/String.py +80 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/Types/__init__.py +76 -0
- DefPixel/DataAccessObject/Implements/PostgreSQL/__init__.py +85 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Configuration.py +16 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Connection.py +96 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Constraint.py +9 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Constraints/ForeignKey.py +16 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Constraints/PrimaryKey.py +15 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Constraints/Unique.py +25 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Constraints/__init__.py +11 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Context.py +36 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Cursor.py +87 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Executors/Create.py +115 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Executors/Delete.py +40 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Executors/Drop.py +34 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Executors/Get.py +24 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Executors/Insert.py +59 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Executors/Select.py +127 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Executors/Update.py +44 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Executors/__init__.py +19 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Expr.py +77 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Exprs/Alias.py +25 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Exprs/Is.py +42 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Exprs/__init__.py +13 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Filters/Compare.py +84 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Filters/Operator.py +42 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Filters/String.py +34 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Filters/__init__.py +30 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Function.py +19 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Functions/Common.py +52 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Functions/Condition.py +31 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Functions/__init__.py +16 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Index.py +23 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Joins/FullOuter.py +19 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Joins/Inner.py +19 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Joins/Join.py +39 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Joins/LeftOuter.py +19 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Joins/RightOuter.py +19 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Joins/__init__.py +13 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Mapping.py +303 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Orders/Ascend.py +28 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Orders/Descend.py +28 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Orders/__init__.py +9 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Session.py +60 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Type.py +75 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Types/Binary.py +28 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Types/DateTime.py +42 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Types/Numeric.py +49 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Types/String.py +28 -0
- DefPixel/DataAccessObject/Implements/Sqlite/Types/__init__.py +34 -0
- DefPixel/DataAccessObject/Implements/Sqlite/__init__.py +39 -0
- DefPixel/DataAccessObject/Implements/__init__.py +1 -0
- DefPixel/DataAccessObject/Properties/Database/Context.py +33 -0
- DefPixel/DataAccessObject/Properties/Database/Cursor.py +27 -0
- DefPixel/DataAccessObject/Properties/Database/Database.py +48 -0
- DefPixel/DataAccessObject/Properties/Database/Executor.py +38 -0
- DefPixel/DataAccessObject/Properties/Database/Executors.py +31 -0
- DefPixel/DataAccessObject/Properties/Database/Fetch.py +37 -0
- DefPixel/DataAccessObject/Properties/Database/Filter.py +21 -0
- DefPixel/DataAccessObject/Properties/Database/Run.py +39 -0
- DefPixel/DataAccessObject/Properties/Database/Session.py +36 -0
- DefPixel/DataAccessObject/Properties/Database/__init__.py +25 -0
- DefPixel/DataAccessObject/Properties/Dataclass.py +25 -0
- DefPixel/DataAccessObject/Properties/Document/Document.py +36 -0
- DefPixel/DataAccessObject/Properties/Document/__init__.py +7 -0
- DefPixel/DataAccessObject/Properties/Index/Index.py +48 -0
- DefPixel/DataAccessObject/Properties/Index/__init__.py +7 -0
- DefPixel/DataAccessObject/Properties/KeyValue/KeyValue.py +44 -0
- DefPixel/DataAccessObject/Properties/KeyValue/__init__.py +7 -0
- DefPixel/DataAccessObject/Properties/__init__.py +15 -0
- DefPixel/DataAccessObject/__init__.py +9 -0
- DefPixel/Validator/Pattern.py +36 -0
- DefPixel/Validator/Patterns/Array.py +30 -0
- DefPixel/Validator/Patterns/Common.py +92 -0
- DefPixel/Validator/Patterns/Compare.py +180 -0
- DefPixel/Validator/Patterns/Condition.py +60 -0
- DefPixel/Validator/Patterns/DataObject.py +85 -0
- DefPixel/Validator/Patterns/DateTime.py +111 -0
- DefPixel/Validator/Patterns/Number.py +43 -0
- DefPixel/Validator/Patterns/Object.py +150 -0
- DefPixel/Validator/Patterns/Size.py +110 -0
- DefPixel/Validator/Patterns/String.py +85 -0
- DefPixel/Validator/Patterns/Type.py +350 -0
- DefPixel/Validator/Patterns/__init__.py +137 -0
- DefPixel/Validator/Validate.py +29 -0
- DefPixel/Validator/Validator.py +30 -0
- DefPixel/Validator/__init__.py +11 -0
- DefPixel/__init__.py +0 -0
- defpixel-0.1.4.dist-info/METADATA +177 -0
- defpixel-0.1.4.dist-info/RECORD +155 -0
- defpixel-0.1.4.dist-info/WHEEL +6 -0
- defpixel-0.1.4.dist-info/licenses/LICENSE +674 -0
- defpixel-0.1.4.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
from dataclasses import MISSING
|
|
4
|
+
from datetime import datetime
|
|
5
|
+
from ..Type import Type
|
|
6
|
+
|
|
7
|
+
__all__ = (
|
|
8
|
+
'DateTime',
|
|
9
|
+
'Timestamp',
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def to_datetime(value):
|
|
14
|
+
if isinstance(value, str):
|
|
15
|
+
return datetime.fromisoformat(value)
|
|
16
|
+
if isinstance(value, float):
|
|
17
|
+
return datetime.fromtimestamp(value)
|
|
18
|
+
return value
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class DateTime(Type, typestr='DATETIME'):
|
|
22
|
+
"""Date-time specification supporting ISO string and float timestamp conversion."""
|
|
23
|
+
|
|
24
|
+
def __init__(
|
|
25
|
+
self,
|
|
26
|
+
name=None,
|
|
27
|
+
va=None,
|
|
28
|
+
null=False,
|
|
29
|
+
default=MISSING,
|
|
30
|
+
):
|
|
31
|
+
super().__init__(
|
|
32
|
+
key=name,
|
|
33
|
+
type=datetime,
|
|
34
|
+
va=to_datetime if va is None else va,
|
|
35
|
+
null=null,
|
|
36
|
+
default=default,
|
|
37
|
+
)
|
|
38
|
+
return
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class Timestamp(DateTime, typestr='TIMESTAMP'):
|
|
42
|
+
"""Date-time specification using a TIMESTAMP declaration."""
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
from dataclasses import MISSING
|
|
4
|
+
from ..Type import Type
|
|
5
|
+
|
|
6
|
+
__all__ = (
|
|
7
|
+
'Integer',
|
|
8
|
+
'Float',
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class Integer(Type, typestr='INTEGER'):
|
|
13
|
+
"""Integer column specification."""
|
|
14
|
+
|
|
15
|
+
def __init__(
|
|
16
|
+
self,
|
|
17
|
+
name=None,
|
|
18
|
+
va=None,
|
|
19
|
+
null=False,
|
|
20
|
+
default=MISSING,
|
|
21
|
+
):
|
|
22
|
+
super().__init__(
|
|
23
|
+
key=name,
|
|
24
|
+
type=int,
|
|
25
|
+
va=va,
|
|
26
|
+
null=null,
|
|
27
|
+
default=default,
|
|
28
|
+
)
|
|
29
|
+
return
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class Float(Type, typestr='REAL'):
|
|
33
|
+
"""Floating-point column specification."""
|
|
34
|
+
|
|
35
|
+
def __init__(
|
|
36
|
+
self,
|
|
37
|
+
name=None,
|
|
38
|
+
va=None,
|
|
39
|
+
null=False,
|
|
40
|
+
default=MISSING,
|
|
41
|
+
):
|
|
42
|
+
super().__init__(
|
|
43
|
+
key=name,
|
|
44
|
+
type=float,
|
|
45
|
+
va=va,
|
|
46
|
+
null=null,
|
|
47
|
+
default=default,
|
|
48
|
+
)
|
|
49
|
+
return
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
from dataclasses import MISSING
|
|
4
|
+
from ..Type import Type
|
|
5
|
+
|
|
6
|
+
__all__ = (
|
|
7
|
+
'Text',
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Text(Type, typestr='TEXT'):
|
|
12
|
+
"""Text column specification."""
|
|
13
|
+
|
|
14
|
+
def __init__(
|
|
15
|
+
self,
|
|
16
|
+
name=None,
|
|
17
|
+
va=None,
|
|
18
|
+
null=False,
|
|
19
|
+
default=MISSING,
|
|
20
|
+
):
|
|
21
|
+
super().__init__(
|
|
22
|
+
key=name,
|
|
23
|
+
type=str,
|
|
24
|
+
va=va,
|
|
25
|
+
null=null,
|
|
26
|
+
default=default,
|
|
27
|
+
)
|
|
28
|
+
return
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
from .Numeric import (
|
|
4
|
+
Integer,
|
|
5
|
+
Float,
|
|
6
|
+
)
|
|
7
|
+
from .String import Text
|
|
8
|
+
from .Binary import Binary
|
|
9
|
+
from .DateTime import (
|
|
10
|
+
DateTime,
|
|
11
|
+
Timestamp,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
__all__ = (
|
|
15
|
+
'Integer', 'INTEGER',
|
|
16
|
+
'Float', 'FLOAT', 'REAL',
|
|
17
|
+
'Text', 'TEXT', 'STRING',
|
|
18
|
+
'Binary', 'BLOB',
|
|
19
|
+
'DateTime', 'DATETIME',
|
|
20
|
+
'Timestamp', 'TIMESTAMP',
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
# NUMERIC
|
|
24
|
+
INTEGER = Integer
|
|
25
|
+
FLOAT = Float
|
|
26
|
+
REAL = Float
|
|
27
|
+
# TEXT
|
|
28
|
+
TEXT = Text
|
|
29
|
+
STRING = Text
|
|
30
|
+
# BINARY
|
|
31
|
+
BLOB = Binary
|
|
32
|
+
# DATETIME
|
|
33
|
+
DATETIME = DateTime
|
|
34
|
+
TIMESTAMP = Timestamp
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
from .Configuration import Configuration
|
|
4
|
+
from .Connection import Connection
|
|
5
|
+
from .Cursor import Cursor
|
|
6
|
+
from .Session import Session
|
|
7
|
+
from .Context import Context
|
|
8
|
+
|
|
9
|
+
from .Mapping import (
|
|
10
|
+
column,
|
|
11
|
+
table,
|
|
12
|
+
view,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
from .Constraint import Constraint
|
|
16
|
+
from .Index import Index
|
|
17
|
+
from .Expr import Expr
|
|
18
|
+
from .Function import Function
|
|
19
|
+
|
|
20
|
+
from sqlite3 import register_adapter
|
|
21
|
+
from datetime import datetime
|
|
22
|
+
|
|
23
|
+
__all__ = (
|
|
24
|
+
'Configuration',
|
|
25
|
+
'Connection',
|
|
26
|
+
'Cursor',
|
|
27
|
+
'Session',
|
|
28
|
+
'Context',
|
|
29
|
+
'column',
|
|
30
|
+
'table',
|
|
31
|
+
'view',
|
|
32
|
+
'Constraint',
|
|
33
|
+
'Index',
|
|
34
|
+
'Expr',
|
|
35
|
+
'Function',
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
register_adapter(datetime, datetime.isoformat)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
from abc import abstractmethod
|
|
4
|
+
from typing import (
|
|
5
|
+
Protocol,
|
|
6
|
+
runtime_checkable,
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
__all__ = (
|
|
10
|
+
'Context'
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@runtime_checkable
|
|
15
|
+
class Context(Protocol):
|
|
16
|
+
"""Protocol for database execution results."""
|
|
17
|
+
|
|
18
|
+
@abstractmethod
|
|
19
|
+
def rows(self):
|
|
20
|
+
raise NotImplementedError('{} must be implemented rows'.format(self.__class__.__name__))
|
|
21
|
+
|
|
22
|
+
@abstractmethod
|
|
23
|
+
def row(self):
|
|
24
|
+
raise NotImplementedError('{} must be implemented row'.format(self.__class__.__name__))
|
|
25
|
+
|
|
26
|
+
@abstractmethod
|
|
27
|
+
def count(self):
|
|
28
|
+
raise NotImplementedError('{} must be implemented count'.format(self.__class__.__name__))
|
|
29
|
+
|
|
30
|
+
@property
|
|
31
|
+
@abstractmethod
|
|
32
|
+
def query(self):
|
|
33
|
+
raise NotImplementedError('{} must be implemented query'.format(self.__class__.__name__))
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
from .Context import Context
|
|
4
|
+
|
|
5
|
+
from abc import abstractmethod
|
|
6
|
+
from typing import (
|
|
7
|
+
Protocol,
|
|
8
|
+
runtime_checkable,
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
__all__ = (
|
|
12
|
+
'Cursor'
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@runtime_checkable
|
|
17
|
+
class Cursor(Protocol):
|
|
18
|
+
"""Protocol for database cursors."""
|
|
19
|
+
|
|
20
|
+
@abstractmethod
|
|
21
|
+
def execute(self, sql, *args, **kwargs) -> Context:
|
|
22
|
+
raise NotImplementedError('{} must be implemented execute'.format(self.__class__.__name__))
|
|
23
|
+
|
|
24
|
+
@abstractmethod
|
|
25
|
+
def executes(self, sql, *args, **kwargs) -> Context:
|
|
26
|
+
raise NotImplementedError('{} must be implemented executes'.format(self.__class__.__name__))
|
|
27
|
+
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
from .Context import Context
|
|
4
|
+
from .Cursor import Cursor
|
|
5
|
+
from .Session import Session
|
|
6
|
+
|
|
7
|
+
from abc import abstractmethod
|
|
8
|
+
from typing import (
|
|
9
|
+
Protocol,
|
|
10
|
+
runtime_checkable,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
__all__ = (
|
|
14
|
+
'Database'
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@runtime_checkable
|
|
19
|
+
class Database(Protocol):
|
|
20
|
+
"""Protocol for SQL execution and transaction control."""
|
|
21
|
+
|
|
22
|
+
@abstractmethod
|
|
23
|
+
def begin(self):
|
|
24
|
+
raise NotImplementedError('{} must be implemented begin'.format(self.__class__.__name__))
|
|
25
|
+
|
|
26
|
+
@abstractmethod
|
|
27
|
+
def execute(self, sql, *args, **kwargs) -> Context:
|
|
28
|
+
raise NotImplementedError('{} must be implemented execute'.format(self.__class__.__name__))
|
|
29
|
+
|
|
30
|
+
@abstractmethod
|
|
31
|
+
def executes(self, sql, *args, **kwargs) -> Context:
|
|
32
|
+
raise NotImplementedError('{} must be implemented executes'.format(self.__class__.__name__))
|
|
33
|
+
|
|
34
|
+
@abstractmethod
|
|
35
|
+
def cursor(self) -> Cursor:
|
|
36
|
+
raise NotImplementedError('{} must be implemented Cursor'.format(self.__class__.__name__))
|
|
37
|
+
|
|
38
|
+
@abstractmethod
|
|
39
|
+
def session(self) -> Session:
|
|
40
|
+
raise NotImplementedError('{} must be implemented session'.format(self.__class__.__name__))
|
|
41
|
+
|
|
42
|
+
@abstractmethod
|
|
43
|
+
def commit(self):
|
|
44
|
+
raise NotImplementedError('{} must be implemented commit'.format(self.__class__.__name__))
|
|
45
|
+
|
|
46
|
+
@abstractmethod
|
|
47
|
+
def rollback(self):
|
|
48
|
+
raise NotImplementedError('{} must be implemented rollback'.format(self.__class__.__name__))
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
from ..Dataclass import Dataclass
|
|
4
|
+
|
|
5
|
+
from abc import abstractmethod
|
|
6
|
+
from typing import (
|
|
7
|
+
Union,
|
|
8
|
+
Sequence,
|
|
9
|
+
Mapping,
|
|
10
|
+
Type,
|
|
11
|
+
Protocol,
|
|
12
|
+
runtime_checkable,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
__all__ = (
|
|
17
|
+
'Executor'
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@runtime_checkable
|
|
22
|
+
class Executor(Protocol):
|
|
23
|
+
"""Protocol exposing a query and its execution arguments."""
|
|
24
|
+
|
|
25
|
+
@abstractmethod
|
|
26
|
+
def __init__(self, o: Type[Dataclass]):
|
|
27
|
+
pass
|
|
28
|
+
|
|
29
|
+
@property
|
|
30
|
+
@abstractmethod
|
|
31
|
+
def query(self) -> str:
|
|
32
|
+
pass
|
|
33
|
+
|
|
34
|
+
@property
|
|
35
|
+
@abstractmethod
|
|
36
|
+
def args(self) -> Union[Sequence, Mapping]:
|
|
37
|
+
pass
|
|
38
|
+
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
from ..Dataclass import Dataclass
|
|
4
|
+
|
|
5
|
+
from .Executor import Executor
|
|
6
|
+
|
|
7
|
+
from abc import abstractmethod
|
|
8
|
+
|
|
9
|
+
from typing import (
|
|
10
|
+
Type,
|
|
11
|
+
Iterator,
|
|
12
|
+
Protocol,
|
|
13
|
+
runtime_checkable,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
__all__ = (
|
|
17
|
+
'Executors'
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@runtime_checkable
|
|
22
|
+
class Executors(Protocol):
|
|
23
|
+
"""Protocol for iterating over multiple Executors."""
|
|
24
|
+
|
|
25
|
+
@abstractmethod
|
|
26
|
+
def __init__(self, o: Type[Dataclass]):
|
|
27
|
+
pass
|
|
28
|
+
|
|
29
|
+
@abstractmethod
|
|
30
|
+
def __iter__(self) -> Iterator[Executor]:
|
|
31
|
+
pass
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
from ..Dataclass import Dataclass
|
|
4
|
+
|
|
5
|
+
from abc import abstractmethod
|
|
6
|
+
|
|
7
|
+
from .Filter import Filter
|
|
8
|
+
|
|
9
|
+
from typing import (
|
|
10
|
+
Union,
|
|
11
|
+
Dict,
|
|
12
|
+
List,
|
|
13
|
+
Type,
|
|
14
|
+
TypeVar,
|
|
15
|
+
Optional,
|
|
16
|
+
Protocol,
|
|
17
|
+
runtime_checkable,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
__all__ = (
|
|
21
|
+
'Fetch'
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
T = TypeVar('T', bound=Dataclass)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@runtime_checkable
|
|
28
|
+
class Fetch(Protocol):
|
|
29
|
+
"""Protocol for converting query results into models or dictionaries."""
|
|
30
|
+
@abstractmethod
|
|
31
|
+
def fetch(
|
|
32
|
+
self,
|
|
33
|
+
cursor,
|
|
34
|
+
filter: Optional[Filter] = None,
|
|
35
|
+
fetch: Optional[Type[T]] = None,
|
|
36
|
+
) -> Optional[Union[Dict, T, List[Dict], List[T]]]:
|
|
37
|
+
raise NotImplementedError('{} must be implemented fetch'.format(self.__class__.__name__))
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
from abc import abstractmethod
|
|
4
|
+
|
|
5
|
+
from typing import (
|
|
6
|
+
Dict,
|
|
7
|
+
Protocol,
|
|
8
|
+
runtime_checkable,
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
__all__ = (
|
|
12
|
+
'Filter',
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@runtime_checkable
|
|
17
|
+
class Filter(Protocol):
|
|
18
|
+
"""Callable protocol for transforming result rows."""
|
|
19
|
+
@abstractmethod
|
|
20
|
+
def __call__(self, row: Dict) -> Dict:
|
|
21
|
+
raise NotImplementedError('{} must be implemented __call__'.format(self.__class__.__name__))
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
from ..Dataclass import Dataclass
|
|
4
|
+
|
|
5
|
+
from abc import abstractmethod
|
|
6
|
+
|
|
7
|
+
from .Executors import Executors
|
|
8
|
+
from .Executor import Executor
|
|
9
|
+
from .Filter import Filter
|
|
10
|
+
|
|
11
|
+
from typing import (
|
|
12
|
+
Optional,
|
|
13
|
+
Type,
|
|
14
|
+
TypeVar,
|
|
15
|
+
Union,
|
|
16
|
+
List,
|
|
17
|
+
Dict,
|
|
18
|
+
Protocol,
|
|
19
|
+
runtime_checkable,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
T = TypeVar('T', bound=Dataclass)
|
|
23
|
+
|
|
24
|
+
__all__ = (
|
|
25
|
+
'Run'
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@runtime_checkable
|
|
30
|
+
class Run(Protocol):
|
|
31
|
+
"""Protocol for executing Executors."""
|
|
32
|
+
@abstractmethod
|
|
33
|
+
def run(
|
|
34
|
+
self,
|
|
35
|
+
executor: Union[Executor, Executors],
|
|
36
|
+
filter: Optional[Filter] = None,
|
|
37
|
+
fetch: Optional[Type[T]] = None,
|
|
38
|
+
) -> Optional[Union[T, List[T], Dict, List[Dict]]]:
|
|
39
|
+
raise NotImplementedError('{} must be implemented run'.format(self.__class__.__name__))
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
from abc import abstractmethod
|
|
4
|
+
from typing import (
|
|
5
|
+
Protocol,
|
|
6
|
+
runtime_checkable,
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
__all__ = (
|
|
10
|
+
'Session'
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@runtime_checkable
|
|
15
|
+
class Session(Protocol):
|
|
16
|
+
"""Protocol for database sessions."""
|
|
17
|
+
|
|
18
|
+
@abstractmethod
|
|
19
|
+
def execute(self, sql, *args, **kwargs):
|
|
20
|
+
raise NotImplementedError('{} must be implemented execute'.format(self.__class__.__name__))
|
|
21
|
+
|
|
22
|
+
@abstractmethod
|
|
23
|
+
def executes(self, sql, *args, **kwargs):
|
|
24
|
+
raise NotImplementedError('{} must be implemented execute'.format(self.__class__.__name__))
|
|
25
|
+
|
|
26
|
+
@abstractmethod
|
|
27
|
+
def rows(self):
|
|
28
|
+
raise NotImplementedError('{} must be implemented rows'.format(self.__class__.__name__))
|
|
29
|
+
|
|
30
|
+
@abstractmethod
|
|
31
|
+
def row(self):
|
|
32
|
+
raise NotImplementedError('{} must be implemented row'.format(self.__class__.__name__))
|
|
33
|
+
|
|
34
|
+
@abstractmethod
|
|
35
|
+
def count(self):
|
|
36
|
+
raise NotImplementedError('{} must be implemented count'.format(self.__class__.__name__))
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
from .Database import Database
|
|
4
|
+
from .Context import Context
|
|
5
|
+
from .Cursor import Cursor
|
|
6
|
+
from .Session import Session
|
|
7
|
+
|
|
8
|
+
from .Executor import Executor
|
|
9
|
+
from .Executors import Executors
|
|
10
|
+
|
|
11
|
+
from .Run import Run
|
|
12
|
+
from .Fetch import Fetch
|
|
13
|
+
from .Filter import Filter
|
|
14
|
+
|
|
15
|
+
__all__ = (
|
|
16
|
+
'Database',
|
|
17
|
+
'Context',
|
|
18
|
+
'Cursor',
|
|
19
|
+
'Session',
|
|
20
|
+
'Run',
|
|
21
|
+
'Filter',
|
|
22
|
+
'Executor',
|
|
23
|
+
'Executors',
|
|
24
|
+
'Fetch',
|
|
25
|
+
)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
from dataclasses import Field
|
|
4
|
+
from typing import (
|
|
5
|
+
Any,
|
|
6
|
+
ClassVar,
|
|
7
|
+
Dict,
|
|
8
|
+
Protocol,
|
|
9
|
+
runtime_checkable,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
__all__ = (
|
|
13
|
+
'Dataclass',
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@runtime_checkable
|
|
18
|
+
class Dataclass(Protocol):
|
|
19
|
+
"""Structural type contract exposing standard dataclass field information.
|
|
20
|
+
|
|
21
|
+
Inheritance is not required, and this contract does not guarantee dataclass identity at runtime.
|
|
22
|
+
DAO implementations must validate inputs using is_dataclass().
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
__dataclass_fields__: ClassVar[Dict[str, Field[Any]]]
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
from abc import abstractmethod
|
|
4
|
+
from typing import (
|
|
5
|
+
Protocol,
|
|
6
|
+
runtime_checkable,
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
__all__ = (
|
|
10
|
+
'Document'
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@runtime_checkable
|
|
15
|
+
class Document(Protocol):
|
|
16
|
+
"""Protocol for document storage and retrieval."""
|
|
17
|
+
|
|
18
|
+
@abstractmethod
|
|
19
|
+
def create(self, doc, **kwargs):
|
|
20
|
+
raise NotImplementedError('{} must be implemented create'.format(self.__class__.__name__))
|
|
21
|
+
|
|
22
|
+
@abstractmethod
|
|
23
|
+
def set(self, doc, **kwargs):
|
|
24
|
+
raise NotImplementedError('{} must be implemented set'.format(self.__class__.__name__))
|
|
25
|
+
|
|
26
|
+
@abstractmethod
|
|
27
|
+
def get(self, doc, **kwargs):
|
|
28
|
+
raise NotImplementedError('{} must be implemented get'.format(self.__class__.__name__))
|
|
29
|
+
|
|
30
|
+
@abstractmethod
|
|
31
|
+
def query(self, doc, **kwargs):
|
|
32
|
+
raise NotImplementedError('{} must be implemented find'.format(self.__class__.__name__))
|
|
33
|
+
|
|
34
|
+
@abstractmethod
|
|
35
|
+
def remove(self, doc, **kwargs):
|
|
36
|
+
raise NotImplementedError('{} must be implemented remove'.format(self.__class__.__name__))
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
from abc import abstractmethod
|
|
4
|
+
from typing import (
|
|
5
|
+
Protocol,
|
|
6
|
+
runtime_checkable,
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
__all__ = (
|
|
10
|
+
'Index'
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@runtime_checkable
|
|
15
|
+
class Index(Protocol):
|
|
16
|
+
"""Protocol for index-based storage and search."""
|
|
17
|
+
|
|
18
|
+
@abstractmethod
|
|
19
|
+
def create(self, index, *args, **kwargs):
|
|
20
|
+
raise NotImplementedError('{} must be implemented create'.format(self.__class__.__name__))
|
|
21
|
+
|
|
22
|
+
@abstractmethod
|
|
23
|
+
def delete(self, index):
|
|
24
|
+
raise NotImplementedError('{} must be implemented delete'.format(self.__class__.__name__))
|
|
25
|
+
|
|
26
|
+
@abstractmethod
|
|
27
|
+
def total(self, index):
|
|
28
|
+
raise NotImplementedError('{} must be implemented count'.format(self.__class__.__name__))
|
|
29
|
+
|
|
30
|
+
@abstractmethod
|
|
31
|
+
def set(self, index, *args, **kwargs):
|
|
32
|
+
raise NotImplementedError('{} must be implemented set'.format(self.__class__.__name__))
|
|
33
|
+
|
|
34
|
+
@abstractmethod
|
|
35
|
+
def get(self, index, id):
|
|
36
|
+
raise NotImplementedError('{} must be implemented get'.format(self.__class__.__name__))
|
|
37
|
+
|
|
38
|
+
@abstractmethod
|
|
39
|
+
def exists(self, index, id):
|
|
40
|
+
raise NotImplementedError('{} must be implemented exists'.format(self.__class__.__name__))
|
|
41
|
+
|
|
42
|
+
@abstractmethod
|
|
43
|
+
def count(self, index, *args, **kwargs):
|
|
44
|
+
raise NotImplementedError('{} must be implemented search'.format(self.__class__.__name__))
|
|
45
|
+
|
|
46
|
+
@abstractmethod
|
|
47
|
+
def query(self, index, *args, **kwargs):
|
|
48
|
+
raise NotImplementedError('{} must be implemented search'.format(self.__class__.__name__))
|