DefPixel 0.1.5__83-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.
Files changed (44) hide show
  1. DefPixel/DataAccessObject/Configuration.py +15 -0
  2. DefPixel/DataAccessObject/Connection.py +25 -0
  3. DefPixel/DataAccessObject/Implements/__init__.py +1 -0
  4. DefPixel/DataAccessObject/Properties/Database/Context.py +33 -0
  5. DefPixel/DataAccessObject/Properties/Database/Cursor.py +27 -0
  6. DefPixel/DataAccessObject/Properties/Database/Database.py +48 -0
  7. DefPixel/DataAccessObject/Properties/Database/Executor.py +38 -0
  8. DefPixel/DataAccessObject/Properties/Database/Executors.py +31 -0
  9. DefPixel/DataAccessObject/Properties/Database/Fetch.py +37 -0
  10. DefPixel/DataAccessObject/Properties/Database/Filter.py +21 -0
  11. DefPixel/DataAccessObject/Properties/Database/Run.py +39 -0
  12. DefPixel/DataAccessObject/Properties/Database/Session.py +36 -0
  13. DefPixel/DataAccessObject/Properties/Database/__init__.py +25 -0
  14. DefPixel/DataAccessObject/Properties/Dataclass.py +25 -0
  15. DefPixel/DataAccessObject/Properties/Document/Document.py +36 -0
  16. DefPixel/DataAccessObject/Properties/Document/__init__.py +7 -0
  17. DefPixel/DataAccessObject/Properties/Index/Index.py +48 -0
  18. DefPixel/DataAccessObject/Properties/Index/__init__.py +7 -0
  19. DefPixel/DataAccessObject/Properties/KeyValue/KeyValue.py +44 -0
  20. DefPixel/DataAccessObject/Properties/KeyValue/__init__.py +7 -0
  21. DefPixel/DataAccessObject/Properties/__init__.py +15 -0
  22. DefPixel/DataAccessObject/__init__.py +9 -0
  23. DefPixel/Validator/Pattern.py +36 -0
  24. DefPixel/Validator/Patterns/Array.py +30 -0
  25. DefPixel/Validator/Patterns/Common.py +92 -0
  26. DefPixel/Validator/Patterns/Compare.py +180 -0
  27. DefPixel/Validator/Patterns/Condition.py +60 -0
  28. DefPixel/Validator/Patterns/DataObject.py +85 -0
  29. DefPixel/Validator/Patterns/DateTime.py +111 -0
  30. DefPixel/Validator/Patterns/Number.py +43 -0
  31. DefPixel/Validator/Patterns/Object.py +150 -0
  32. DefPixel/Validator/Patterns/Size.py +110 -0
  33. DefPixel/Validator/Patterns/String.py +85 -0
  34. DefPixel/Validator/Patterns/Type.py +350 -0
  35. DefPixel/Validator/Patterns/__init__.py +137 -0
  36. DefPixel/Validator/Validate.py +29 -0
  37. DefPixel/Validator/Validator.py +30 -0
  38. DefPixel/Validator/__init__.py +11 -0
  39. DefPixel/__init__.py +0 -0
  40. defpixel-0.1.5.dist-info/METADATA +182 -0
  41. defpixel-0.1.5.dist-info/RECORD +44 -0
  42. defpixel-0.1.5.dist-info/WHEEL +6 -0
  43. defpixel-0.1.5.dist-info/licenses/LICENSE +674 -0
  44. defpixel-0.1.5.dist-info/top_level.txt +1 -0
@@ -0,0 +1,30 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ from .Pattern import Pattern
4
+
5
+ __all__ = (
6
+ 'Validator',
7
+ )
8
+
9
+
10
+ class Validator(object):
11
+ """
12
+ Validator Class
13
+ """
14
+ def __init__(self, *args):
15
+ for pattern in args:
16
+ if not isinstance(pattern, Pattern):
17
+ raise RuntimeError('{} must be based {}'.format(pattern, Pattern))
18
+ self.patterns = args
19
+ return
20
+
21
+ def __call__(self, parameter):
22
+ for pattern in self.patterns:
23
+ parameter = pattern(parameter)
24
+ return parameter
25
+
26
+ def __repr__(self):
27
+ return 'Validator({})'.format(
28
+ ', '.join([repr(p) for p in self.patterns])
29
+ )
30
+
@@ -0,0 +1,11 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ from .Validator import Validator
4
+ from .Pattern import Pattern
5
+ from .Validate import Validate
6
+
7
+ __all__ = (
8
+ 'Validator',
9
+ 'Pattern',
10
+ 'Validate',
11
+ )
DefPixel/__init__.py ADDED
File without changes
@@ -0,0 +1,182 @@
1
+ Metadata-Version: 2.4
2
+ Name: DefPixel
3
+ Version: 0.1.5
4
+ Summary: The Python toolkit to define data connections, design data models, and dive into your data
5
+ Home-page: https://github.com/yong5eon/DefPixel
6
+ Author: Heo Yongseon
7
+ Project-URL: Source, https://github.com/yong5eon/DefPixel
8
+ Project-URL: Issues, https://github.com/yong5eon/DefPixel/issues
9
+ Project-URL: Releases, https://github.com/yong5eon/DefPixel/releases
10
+ Classifier: Programming Language :: Python :: 3.10
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Classifier: Programming Language :: Python :: 3.14
15
+ Requires-Python: >=3.10
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Provides-Extra: sqlite
19
+ Requires-Dist: DefPixel-Sqlite==0.1.5; extra == "sqlite"
20
+ Provides-Extra: postgresql
21
+ Requires-Dist: DefPixel-PostgreSQL==0.1.5; extra == "postgresql"
22
+ Dynamic: author
23
+ Dynamic: classifier
24
+ Dynamic: description
25
+ Dynamic: description-content-type
26
+ Dynamic: home-page
27
+ Dynamic: license-file
28
+ Dynamic: project-url
29
+ Dynamic: provides-extra
30
+ Dynamic: requires-python
31
+ Dynamic: summary
32
+
33
+ # DefPixel
34
+
35
+ **Define your pixels. Design your voxels.**<br>
36
+ Define your connections, Design your models, and Dive into your data in Python.
37
+
38
+ DefPixel is a Python library for defining data source connections, models, and access. Use a provided data access implementation or build your own, and work with data directly or through standard dataclasses.
39
+
40
+ ## Connect · model · use
41
+
42
+ - Define your connections: storage-specific configuration and data access capabilities.
43
+ - Design your models: storage specifications and validation rules attached to standard dataclasses.
44
+ - Dive into your data: direct access without models, or storage and retrieval through models.
45
+
46
+ Configuration and Connection provide connection foundations. Database, KeyValue, Document, and Index Protocols describe capabilities. Modeling approaches and support vary by implementation. Validators also provide independent value validation and conversion.
47
+
48
+ ## Requirements and installation
49
+
50
+ Python 3.10+ is required.
51
+ The base `pip install DefPixel` installs only the core, without implementation code.
52
+
53
+ ### Sqlite
54
+
55
+ Select the Sqlite implementation with the `Sqlite` extra. It uses Python's standard-library `sqlite3`. Model-based usage requires Sqlite 3.35+ as used by Python.
56
+
57
+ ```shell
58
+ pip install "DefPixel[Sqlite]"
59
+ ```
60
+
61
+ ### PostgreSQL
62
+
63
+ Install the `PostgreSQL` extra to include the implementation and PostgreSQL driver. A running PostgreSQL 15–18 server is required. This installation excludes Sqlite.
64
+
65
+ ```shell
66
+ pip install "DefPixel[PostgreSQL]"
67
+ ```
68
+
69
+ Use `pip install "DefPixel[Sqlite,PostgreSQL]"` for both implementations. Each extra selects a separate, same-version distribution; existing import paths are unchanged. Before migrating an older integrated installation, uninstall DefPixel and any implementation distributions, then reinstall with the required extras. Sqlite is no longer included in the base installation. Omitting an extra later does not remove an already installed implementation.
70
+
71
+ ## Usage at a glance
72
+
73
+ ### Database
74
+
75
+ #### Sqlite
76
+
77
+ Execute SQL directly for dictionary results or map standard dataclasses to tables and retrieve objects. This complete example requires Sqlite 3.35+ as used by Python.
78
+
79
+ ```python
80
+ from dataclasses import dataclass
81
+ from DefPixel.DataAccessObject.Implements.Sqlite import (
82
+ Configuration, Connection, column, table,
83
+ )
84
+ from DefPixel.DataAccessObject.Implements.Sqlite.Constraints import PrimaryKey
85
+ from DefPixel.DataAccessObject.Implements.Sqlite.Executors import Create, Insert, Select
86
+ from DefPixel.DataAccessObject.Implements.Sqlite.Types import Integer, Text
87
+
88
+
89
+ @table(name='users', constraints=(PrimaryKey('id'),))
90
+ @dataclass
91
+ class User:
92
+ id: int = column(Integer())
93
+ name: str = column(Text())
94
+
95
+
96
+ connection = Connection(Configuration(':memory:'))
97
+ connection.connect()
98
+ try:
99
+ with connection.session() as session:
100
+ session.run(Create(User))
101
+ session.run(Insert(User).values(id=1, name='Alice'))
102
+
103
+ rows = session.execute(
104
+ 'SELECT id, name FROM users WHERE id = ?', 1,
105
+ ).rows()
106
+ print(rows)
107
+
108
+ users = session.run(Select(User), fetch=User)
109
+ print(users)
110
+ finally:
111
+ connection.close()
112
+ ```
113
+
114
+ Output:
115
+
116
+ ```text
117
+ [{'id': 1, 'name': 'Alice'}]
118
+ [User(id=1, name='Alice')]
119
+ ```
120
+
121
+ Sessions commit on normal completion and roll back on exceptions. Direct SQL does not require models. Models remain ordinary Python objects; attribute assignment does not automatically persist changes. No custom Model base class or Service/Repository/DTO structure is required.
122
+
123
+ #### PostgreSQL
124
+
125
+ PostgreSQL also supports direct SQL alongside dataclass mappings. Install the PostgreSQL extra above and adjust the connection settings for your server. Run this example in a development database: it creates and drops the `defpixel_readme_users` table.
126
+
127
+ ```python
128
+ from dataclasses import dataclass
129
+ from DefPixel.DataAccessObject.Implements.PostgreSQL import (
130
+ Configuration, Connection, Create, Drop, Insert, PrimaryKey, Select, column, table,
131
+ )
132
+ from DefPixel.DataAccessObject.Implements.PostgreSQL.Types import Integer, Text
133
+
134
+
135
+ @table('defpixel_readme_users', constraints=PrimaryKey('defpixel_readme_users_pk', 'id'))
136
+ @dataclass
137
+ class User:
138
+ id: int = column(Integer())
139
+ name: str = column(Text())
140
+
141
+
142
+ connection = Connection(Configuration(
143
+ host='127.0.0.1', port=5432, database='defpixel',
144
+ username='defpixel', password='change-me-local-only',
145
+ ))
146
+ connection.connect()
147
+ try:
148
+ with connection.session() as session:
149
+ session.run(Create(User))
150
+ session.run(Insert(User).values(id=1, name='Alice'))
151
+
152
+ rows = session.execute(
153
+ 'SELECT id, name FROM defpixel_readme_users WHERE id = %s', 1,
154
+ ).rows()
155
+ print(rows)
156
+
157
+ users = session.run(Select(User), fetch=User)
158
+ print(users)
159
+ session.run(Drop(User))
160
+ finally:
161
+ connection.close()
162
+ ```
163
+
164
+ Output:
165
+
166
+ ```text
167
+ [{'id': 1, 'name': 'Alice'}]
168
+ [User(id=1, name='Alice')]
169
+ ```
170
+
171
+ Direct SQL binds positional arguments with `%s` and keyword arguments with `%(name)s`. PostgreSQL constraints take a name as their first argument.
172
+
173
+ ## Supported implementations
174
+
175
+ - Sqlite: direct SQL, dataclass mappings, CRUD, tables, views, constraints, indexes, joins, aggregates, and transactions. Sqlite modeling requires Sqlite 3.35+.
176
+ - PostgreSQL: direct SQL, dataclass mappings, CRUD, schemas, sequences, tables, views, constraints, indexes, joins, aggregate/window/JSON functions, nested transactions, and connection pools. Requires PostgreSQL 15–18 and the `PostgreSQL` extra.
177
+
178
+ ## Build your own
179
+
180
+ Implement the capability Protocols for the store you need, without inheriting a provided implementation or adapting every store to SQL.
181
+
182
+ The source repository includes step-by-step implementation development guides and Sqlite and PostgreSQL user manuals.
@@ -0,0 +1,44 @@
1
+ DefPixel/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ DefPixel/DataAccessObject/Configuration.py,sha256=vX8QcjmRceE469N-KMjd08NDZme8fD0h-k6oFFcvSDQ,321
3
+ DefPixel/DataAccessObject/Connection.py,sha256=Noi8dIBgZ3drfCe37Cq6RAahBNIri50tZbeonCXe0tI,639
4
+ DefPixel/DataAccessObject/__init__.py,sha256=O_GTr0rSz0KddlR8a-Xq0pV81IOsj8-0wBnMSvFwY6w,149
5
+ DefPixel/DataAccessObject/Implements/__init__.py,sha256=iwhKnzeBJLKxpRVjvzwiRE63_zNpIBfaKLITauVph-0,24
6
+ DefPixel/DataAccessObject/Properties/Dataclass.py,sha256=0C3TJUM8yu-xWlG2YSX3Nn_91TeLlZ71iJPwvC38lVw,510
7
+ DefPixel/DataAccessObject/Properties/__init__.py,sha256=o0eygFnqsiVn6mRUKgbvzPX9MRBfXjB0GlbEOvE4HgE,254
8
+ DefPixel/DataAccessObject/Properties/Database/Context.py,sha256=FSfm_kTXHAsqTMLhkeDvlUDGGAPwg6pbs0shgItygbc,747
9
+ DefPixel/DataAccessObject/Properties/Database/Cursor.py,sha256=pcrdtShABO5-frJaFU6V4Sy8Dr53uO9HmnQp0tbGRJE,581
10
+ DefPixel/DataAccessObject/Properties/Database/Database.py,sha256=gml4LCEpWFWPurtp-lTtW8oX1rECNc8py9FnYsHbUKA,1337
11
+ DefPixel/DataAccessObject/Properties/Database/Executor.py,sha256=Uj3wTamWdurcCIIsyNyRtYzr3L2rKm_fbbckTyZNN5E,528
12
+ DefPixel/DataAccessObject/Properties/Database/Executors.py,sha256=uCrA8jzvXDLNDkYqZ9CZopQxICE_bSVt8qE7g3R2zrE,462
13
+ DefPixel/DataAccessObject/Properties/Database/Fetch.py,sha256=63GprAKEYIaRVEJEs4L9XBTsr1fRO9Yjw0l6w-ex28A,663
14
+ DefPixel/DataAccessObject/Properties/Database/Filter.py,sha256=v_lj7w80j88Ec68aNH9_Z7MFQrgtCXrrDzRwgF9F5VY,396
15
+ DefPixel/DataAccessObject/Properties/Database/Run.py,sha256=WLeSy5u2nLoXptXmUZ-CJqqmxCmaENgHAMS2hjWv78k,716
16
+ DefPixel/DataAccessObject/Properties/Database/Session.py,sha256=cvkORRfd6QsOHSsVCAM4j5nmZFD8TBKURSB55-IvZeM,908
17
+ DefPixel/DataAccessObject/Properties/Database/__init__.py,sha256=usBvrpiudUyfJwWFfXXVrGsZ9XaTO4OZUFmB2DFX144,399
18
+ DefPixel/DataAccessObject/Properties/Document/Document.py,sha256=DotRohWuvQCunIgOoYvdNfHmAW6mN-bd5wm5p1Hluys,946
19
+ DefPixel/DataAccessObject/Properties/Document/__init__.py,sha256=-p_0CYWIy3nk1u_EvgvOY4MBiWoIUNfP84NtuEdm3n4,84
20
+ DefPixel/DataAccessObject/Properties/Index/Index.py,sha256=h16ULzdadi5NfZ1VDct14rlojjmWwFdj1Q2HkrTH-UI,1386
21
+ DefPixel/DataAccessObject/Properties/Index/__init__.py,sha256=QeHKZq8mmOk_Lmtx88a8ZbCMMNrZ_TSStviXWEjGDjs,75
22
+ DefPixel/DataAccessObject/Properties/KeyValue/KeyValue.py,sha256=TqvAP7nNDQpoB6mnl0okF_Tr_3rFlBioBYwhGBzuKBQ,1209
23
+ DefPixel/DataAccessObject/Properties/KeyValue/__init__.py,sha256=AZBc44CWC4MVN5sz3sr2H7Fe4h-xDmuK0uBWp97TPYg,84
24
+ DefPixel/Validator/Pattern.py,sha256=gRRlEzS908b9OCXRpFnEG4gujNKCSTlhPUGwWGi-Dqg,674
25
+ DefPixel/Validator/Validate.py,sha256=2Edk1sWh5_4QdYTc1xakDLPXMAWNrrjso1TLi7ZQ4Gg,700
26
+ DefPixel/Validator/Validator.py,sha256=lvJGzDKecKIBAQrfFuSHBRUh6PCxiHRsabul6cYxcdA,556
27
+ DefPixel/Validator/__init__.py,sha256=juhR_lm3XpqU-BUnTjbaYbFNXa_zs9Xi9-x_9EyvJgE,172
28
+ DefPixel/Validator/Patterns/Array.py,sha256=XPc88iPhU2k30TIyMsB6pdDqUO_wjv-5YP96mTHbApc,514
29
+ DefPixel/Validator/Patterns/Common.py,sha256=JJIOAcPO6epnIINaVu5SuwmnQoK3rLQn6vYyZ3JBuX8,1817
30
+ DefPixel/Validator/Patterns/Compare.py,sha256=5xYVvaiQydvIi8WYgIADltSk0tz_ki76k-c89vZsFcw,3726
31
+ DefPixel/Validator/Patterns/Condition.py,sha256=V8iEG9onH6bxlUnqFY8jDdmm6BIx2SBeEJAluVHeEUM,1135
32
+ DefPixel/Validator/Patterns/DataObject.py,sha256=BTdbKGSYs1ebXNXmKP2m3T0iJeTBxIwgwl45gacpuUA,2258
33
+ DefPixel/Validator/Patterns/DateTime.py,sha256=2ejPyRxFbvWf_0FmUrtXTBTvMnp8nakfW_TyCsRY_h4,2515
34
+ DefPixel/Validator/Patterns/Number.py,sha256=k59Ue1Sw-D1iWz8OywjQljPVXdZlTawSl9jBpPjJKKY,919
35
+ DefPixel/Validator/Patterns/Object.py,sha256=94aa5eC35dZyrgBlbAEH5eB7v9YB8k_haru_EBeU1vw,3563
36
+ DefPixel/Validator/Patterns/Size.py,sha256=n-PdMTYNCw0-KN2wqWqK7nN6smVvrGLO4YfwBLlGA9Y,2016
37
+ DefPixel/Validator/Patterns/String.py,sha256=sR4s0GM1J8r1kiOyu4HkDUgIrz-9PvLthHM1IFTgSqw,1805
38
+ DefPixel/Validator/Patterns/Type.py,sha256=-z75Q3vYw6Br7T-gACIZNLV2PLLkFdHn67VcLxTDqEs,8758
39
+ DefPixel/Validator/Patterns/__init__.py,sha256=2Kkk6BrvcLl0C22I0WhGphp2dF55Ig2b3LY0DMDNWm8,1603
40
+ defpixel-0.1.5.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
41
+ defpixel-0.1.5.dist-info/METADATA,sha256=hpCeP5U5YqCGGOXaWTISe6vFlgPjUpOmzyGNJXAkpRE,6865
42
+ defpixel-0.1.5.dist-info/WHEEL,sha256=z2ae0zv_6J4DXSZsovNmpTs3PrmNwb98SjuGdID_M3E,101
43
+ defpixel-0.1.5.dist-info/top_level.txt,sha256=q8GXppLfIcF9XRgxaOnzWmk1HvM4fsQQW3eVlmvsatw,9
44
+ defpixel-0.1.5.dist-info/RECORD,,
@@ -0,0 +1,6 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+ Build: 83
6
+