DefPixel 0.1.6__93-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.6.dist-info/METADATA +188 -0
  41. defpixel-0.1.6.dist-info/RECORD +44 -0
  42. defpixel-0.1.6.dist-info/WHEEL +6 -0
  43. defpixel-0.1.6.dist-info/licenses/LICENSE +674 -0
  44. defpixel-0.1.6.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,188 @@
1
+ Metadata-Version: 2.4
2
+ Name: DefPixel
3
+ Version: 0.1.6
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.6; extra == "sqlite"
20
+ Provides-Extra: postgresql
21
+ Requires-Dist: DefPixel-PostgreSQL==0.1.6; extra == "postgresql"
22
+ Provides-Extra: mariadb
23
+ Requires-Dist: DefPixel-MariaDB==0.1.6; extra == "mariadb"
24
+ Dynamic: author
25
+ Dynamic: classifier
26
+ Dynamic: description
27
+ Dynamic: description-content-type
28
+ Dynamic: home-page
29
+ Dynamic: license-file
30
+ Dynamic: project-url
31
+ Dynamic: provides-extra
32
+ Dynamic: requires-python
33
+ Dynamic: summary
34
+
35
+ # DefPixel
36
+
37
+ **Define your pixels. Design your voxels.**<br>
38
+ Define your connections, Design your models, and Dive into your data in Python.
39
+
40
+ 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.
41
+
42
+ ## Connect · model · use
43
+
44
+ - Define your connections: storage-specific configuration and data access capabilities.
45
+ - Design your models: storage specifications and validation rules attached to standard dataclasses.
46
+ - Dive into your data: direct access without models, or storage and retrieval through models.
47
+
48
+ 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.
49
+
50
+ ## Requirements and installation
51
+
52
+ Python 3.10+ is required.
53
+ The base `pip install DefPixel` installs only the core, without implementation code.
54
+
55
+ ### Sqlite
56
+
57
+ 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.
58
+
59
+ ```shell
60
+ pip install "DefPixel[Sqlite]"
61
+ ```
62
+
63
+ ### PostgreSQL
64
+
65
+ Install the `PostgreSQL` extra to include the implementation and PostgreSQL driver. A running PostgreSQL 15–18 server is required. This installation excludes Sqlite.
66
+
67
+ ```shell
68
+ pip install "DefPixel[PostgreSQL]"
69
+ ```
70
+
71
+ 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.
72
+
73
+ ### MariaDB development status
74
+
75
+ The current source provides MariaDB connections, direct SQL, sessions, native pools, dataclass mapping, types, DDL, model CRUD, SELECT-backed views, query composition, scalar/aggregate/date-time/JSON/spatial/vector functions and JSON_TABLE sources through the `MariaDB` implementation selection. VECTOR types/indexes and vector functions require 11.7+; `MBRCoveredBy` requires 12.0+; JSON_TABLE requires 10.6+. Insert returns the first RETURNING row; Update/Delete return None. Final integration and regression validation remain in progress; YEAR=0 support is deferred. No release containing this feature has been published. Source development uses `python -m pip install -e . --config-settings EXTRAS=MariaDB`; include other implementation names in EXTRAS to keep them selected.
76
+
77
+ ## Usage at a glance
78
+
79
+ ### Database
80
+
81
+ #### Sqlite
82
+
83
+ 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.
84
+
85
+ ```python
86
+ from dataclasses import dataclass
87
+ from DefPixel.DataAccessObject.Implements.Sqlite import (
88
+ Configuration, Connection, column, table,
89
+ )
90
+ from DefPixel.DataAccessObject.Implements.Sqlite.Constraints import PrimaryKey
91
+ from DefPixel.DataAccessObject.Implements.Sqlite.Executors import Create, Insert, Select
92
+ from DefPixel.DataAccessObject.Implements.Sqlite.Types import Integer, Text
93
+
94
+
95
+ @table(name='users', constraints=(PrimaryKey('id'),))
96
+ @dataclass
97
+ class User:
98
+ id: int = column(Integer())
99
+ name: str = column(Text())
100
+
101
+
102
+ connection = Connection(Configuration(':memory:'))
103
+ connection.connect()
104
+ try:
105
+ with connection.session() as session:
106
+ session.run(Create(User))
107
+ session.run(Insert(User).values(id=1, name='Alice'))
108
+
109
+ rows = session.execute(
110
+ 'SELECT id, name FROM users WHERE id = ?', 1,
111
+ ).rows()
112
+ print(rows)
113
+
114
+ users = session.run(Select(User), fetch=User)
115
+ print(users)
116
+ finally:
117
+ connection.close()
118
+ ```
119
+
120
+ Output:
121
+
122
+ ```text
123
+ [{'id': 1, 'name': 'Alice'}]
124
+ [User(id=1, name='Alice')]
125
+ ```
126
+
127
+ 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.
128
+
129
+ #### PostgreSQL
130
+
131
+ 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.
132
+
133
+ ```python
134
+ from dataclasses import dataclass
135
+ from DefPixel.DataAccessObject.Implements.PostgreSQL import (
136
+ Configuration, Connection, Create, Drop, Insert, PrimaryKey, Select, column, table,
137
+ )
138
+ from DefPixel.DataAccessObject.Implements.PostgreSQL.Types import Integer, Text
139
+
140
+
141
+ @table('defpixel_readme_users', constraints=PrimaryKey('defpixel_readme_users_pk', 'id'))
142
+ @dataclass
143
+ class User:
144
+ id: int = column(Integer())
145
+ name: str = column(Text())
146
+
147
+
148
+ connection = Connection(Configuration(
149
+ host='127.0.0.1', port=5432, database='defpixel',
150
+ username='defpixel', password='change-me-local-only',
151
+ ))
152
+ connection.connect()
153
+ try:
154
+ with connection.session() as session:
155
+ session.run(Create(User))
156
+ session.run(Insert(User).values(id=1, name='Alice'))
157
+
158
+ rows = session.execute(
159
+ 'SELECT id, name FROM defpixel_readme_users WHERE id = %s', 1,
160
+ ).rows()
161
+ print(rows)
162
+
163
+ users = session.run(Select(User), fetch=User)
164
+ print(users)
165
+ session.run(Drop(User))
166
+ finally:
167
+ connection.close()
168
+ ```
169
+
170
+ Output:
171
+
172
+ ```text
173
+ [{'id': 1, 'name': 'Alice'}]
174
+ [User(id=1, name='Alice')]
175
+ ```
176
+
177
+ Direct SQL binds positional arguments with `%s` and keyword arguments with `%(name)s`. PostgreSQL constraints take a name as their first argument.
178
+
179
+ ## Supported implementations
180
+
181
+ - Sqlite: direct SQL, dataclass mappings, CRUD, tables, views, constraints, indexes, joins, aggregates, and transactions. Sqlite modeling requires Sqlite 3.35+.
182
+ - 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.
183
+
184
+ ## Build your own
185
+
186
+ Implement the capability Protocols for the store you need, without inheriting a provided implementation or adapting every store to SQL.
187
+
188
+ 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.6.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
41
+ defpixel-0.1.6.dist-info/METADATA,sha256=EuCbb8XMZy83jNotpP2AvOZrF8y2S4e2lVASejc8zdw,7761
42
+ defpixel-0.1.6.dist-info/WHEEL,sha256=n1c91tzQdRhJnh5r2v4lmdEQMpDl6QRzoWBV66tFhkU,101
43
+ defpixel-0.1.6.dist-info/top_level.txt,sha256=q8GXppLfIcF9XRgxaOnzWmk1HvM4fsQQW3eVlmvsatw,9
44
+ defpixel-0.1.6.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: 93
6
+