dbentity 1.0.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.
@@ -0,0 +1,35 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ publish:
9
+ runs-on: ubuntu-latest
10
+ environment: pypi
11
+ permissions:
12
+ id-token: write
13
+
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+
17
+ - name: Set up Python
18
+ uses: actions/setup-python@v5
19
+ with:
20
+ python-version: "3.14"
21
+
22
+ - name: Install build dependencies
23
+ run: pip install build
24
+
25
+ - name: Install package
26
+ run: pip install .
27
+
28
+ - name: Run unit tests
29
+ run: python -m unittest discover -v tests/
30
+
31
+ - name: Build package
32
+ run: python -m build
33
+
34
+ - name: Publish to PyPI
35
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,29 @@
1
+ name: Tests
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ${{ matrix.os }}
12
+ strategy:
13
+ matrix:
14
+ os: [ubuntu-latest, windows-latest]
15
+ python-version: ["3.10", "3.14"]
16
+
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+
20
+ - name: Set up Python ${{ matrix.python-version }}
21
+ uses: actions/setup-python@v5
22
+ with:
23
+ python-version: ${{ matrix.python-version }}
24
+
25
+ - name: Install package
26
+ run: pip install .
27
+
28
+ - name: Run unit tests
29
+ run: python -m unittest discover -v tests/
@@ -0,0 +1,13 @@
1
+ __pycache__
2
+ build
3
+ dist
4
+ .*
5
+ !.gitignore
6
+ !.github
7
+ !.mpyproject
8
+ *.egg-info
9
+ _version.py
10
+ *.md
11
+ !README*.md
12
+ scripts/
13
+ *.whl
dbentity-1.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 Pavel Revak
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,126 @@
1
+ Metadata-Version: 2.4
2
+ Name: dbentity
3
+ Version: 1.0.0
4
+ Summary: Lightweight Python ORM library for PostgreSQL
5
+ Author-email: Pavel Revak <pavel.revak@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/pavelrevak/dbentity
8
+ Keywords: orm,postgresql,database,entity,sql
9
+ Classifier: Development Status :: 5 - Production/Stable
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Topic :: Database
12
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
13
+ Classifier: Programming Language :: Python :: 3
14
+ Requires-Python: >=3.8
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ Dynamic: license-file
18
+
19
+ # dbentity
20
+
21
+ Lightweight Python ORM library for PostgreSQL.
22
+
23
+ ## Installation
24
+
25
+ ```bash
26
+ pip install dbentity
27
+ ```
28
+
29
+ ## Features
30
+
31
+ - Declarative entity definitions with typed attributes
32
+ - Automatic SQL query generation
33
+ - Support for JOIN operations
34
+ - Query builder with boolean logic (AND, OR, NOT)
35
+ - Database migration support
36
+ - No external dependencies
37
+
38
+ ## Quick Start
39
+
40
+ ```python
41
+ from dbentity.db_entity import DbEntity
42
+ from dbentity.attribute import IndexAttribute, StringAttribute, IntegerAttribute
43
+ from dbentity.db_control import OrderByDesc, Limit
44
+
45
+ class User(DbEntity):
46
+ TABLE = 'users'
47
+ ITEMS = (
48
+ IndexAttribute(),
49
+ StringAttribute('name', form_key='user_name'),
50
+ IntegerAttribute('age', minimal=0, maximal=150),
51
+ )
52
+
53
+ # Query with controls
54
+ users = User.db_list(db, OrderByDesc('age'), Limit(10), name='John')
55
+ user = User.db_get(db, uid=123)
56
+
57
+ # Create new entity
58
+ user = User.create(db, name='Jane', age=25)
59
+
60
+ # Update
61
+ user.age = 26
62
+ user.db_save(db)
63
+
64
+ # Delete
65
+ user.db_delete(db)
66
+ ```
67
+
68
+ ## Attribute Types
69
+
70
+ - `IndexAttribute` / `CreateIndexAttribute` - Primary key
71
+ - `StringAttribute` - Text fields
72
+ - `IntegerAttribute` - Integer with optional min/max
73
+ - `FixedPointAttribute` - Decimal numbers
74
+ - `BooleanAttribute` - Boolean values
75
+ - `BytesAttribute` - Binary data
76
+ - `PasswordAttribute` - Password fields (hidden in templates)
77
+ - `DatetimeAttribute` - Datetime values
78
+ - `ConnectionAttribute` - Foreign key relationships
79
+ - `SubElementsAttribute` - One-to-many relationships
80
+
81
+ ## Query Controls
82
+
83
+ ```python
84
+ from dbentity.db_control import (
85
+ Where, And, Or, Not,
86
+ Lt, Gt, Le, Ge,
87
+ OrderBy, OrderByAsc, OrderByDesc,
88
+ Limit, Offset,
89
+ LeftJoin, RightJoin,
90
+ GroupBy,
91
+ )
92
+
93
+ # Complex queries
94
+ users = User.db_list(
95
+ db,
96
+ Or(Where(name='John'), Where(name='Jane')),
97
+ Gt(age=18),
98
+ Lt(age=65),
99
+ OrderByDesc('age'),
100
+ Limit(10),
101
+ )
102
+
103
+ # Joins
104
+ posts = Post.db_list(
105
+ db,
106
+ LeftJoin('author', name='John'),
107
+ OrderByDesc('created_at'),
108
+ )
109
+ ```
110
+
111
+ ## Database Migrations
112
+
113
+ ```python
114
+ from dbentity.db_upgrade import db_upgrade
115
+
116
+ SQL_UPGRADE_FILES = [
117
+ (1, 'upgrade_001.sql'),
118
+ (2, 'upgrade_002.sql'),
119
+ ]
120
+
121
+ db_upgrade(db, log, 'sql/', 'init.sql', SQL_UPGRADE_FILES)
122
+ ```
123
+
124
+ ## License
125
+
126
+ MIT
@@ -0,0 +1,108 @@
1
+ # dbentity
2
+
3
+ Lightweight Python ORM library for PostgreSQL.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install dbentity
9
+ ```
10
+
11
+ ## Features
12
+
13
+ - Declarative entity definitions with typed attributes
14
+ - Automatic SQL query generation
15
+ - Support for JOIN operations
16
+ - Query builder with boolean logic (AND, OR, NOT)
17
+ - Database migration support
18
+ - No external dependencies
19
+
20
+ ## Quick Start
21
+
22
+ ```python
23
+ from dbentity.db_entity import DbEntity
24
+ from dbentity.attribute import IndexAttribute, StringAttribute, IntegerAttribute
25
+ from dbentity.db_control import OrderByDesc, Limit
26
+
27
+ class User(DbEntity):
28
+ TABLE = 'users'
29
+ ITEMS = (
30
+ IndexAttribute(),
31
+ StringAttribute('name', form_key='user_name'),
32
+ IntegerAttribute('age', minimal=0, maximal=150),
33
+ )
34
+
35
+ # Query with controls
36
+ users = User.db_list(db, OrderByDesc('age'), Limit(10), name='John')
37
+ user = User.db_get(db, uid=123)
38
+
39
+ # Create new entity
40
+ user = User.create(db, name='Jane', age=25)
41
+
42
+ # Update
43
+ user.age = 26
44
+ user.db_save(db)
45
+
46
+ # Delete
47
+ user.db_delete(db)
48
+ ```
49
+
50
+ ## Attribute Types
51
+
52
+ - `IndexAttribute` / `CreateIndexAttribute` - Primary key
53
+ - `StringAttribute` - Text fields
54
+ - `IntegerAttribute` - Integer with optional min/max
55
+ - `FixedPointAttribute` - Decimal numbers
56
+ - `BooleanAttribute` - Boolean values
57
+ - `BytesAttribute` - Binary data
58
+ - `PasswordAttribute` - Password fields (hidden in templates)
59
+ - `DatetimeAttribute` - Datetime values
60
+ - `ConnectionAttribute` - Foreign key relationships
61
+ - `SubElementsAttribute` - One-to-many relationships
62
+
63
+ ## Query Controls
64
+
65
+ ```python
66
+ from dbentity.db_control import (
67
+ Where, And, Or, Not,
68
+ Lt, Gt, Le, Ge,
69
+ OrderBy, OrderByAsc, OrderByDesc,
70
+ Limit, Offset,
71
+ LeftJoin, RightJoin,
72
+ GroupBy,
73
+ )
74
+
75
+ # Complex queries
76
+ users = User.db_list(
77
+ db,
78
+ Or(Where(name='John'), Where(name='Jane')),
79
+ Gt(age=18),
80
+ Lt(age=65),
81
+ OrderByDesc('age'),
82
+ Limit(10),
83
+ )
84
+
85
+ # Joins
86
+ posts = Post.db_list(
87
+ db,
88
+ LeftJoin('author', name='John'),
89
+ OrderByDesc('created_at'),
90
+ )
91
+ ```
92
+
93
+ ## Database Migrations
94
+
95
+ ```python
96
+ from dbentity.db_upgrade import db_upgrade
97
+
98
+ SQL_UPGRADE_FILES = [
99
+ (1, 'upgrade_001.sql'),
100
+ (2, 'upgrade_002.sql'),
101
+ ]
102
+
103
+ db_upgrade(db, log, 'sql/', 'init.sql', SQL_UPGRADE_FILES)
104
+ ```
105
+
106
+ ## License
107
+
108
+ MIT
@@ -0,0 +1,6 @@
1
+ """Lightweight Python ORM library for PostgreSQL"""
2
+
3
+ try:
4
+ from dbentity._version import version as __version__
5
+ except ImportError:
6
+ __version__ = "0.0.0"
@@ -0,0 +1,24 @@
1
+ # file generated by vcs-versioning
2
+ # don't change, don't track in version control
3
+ from __future__ import annotations
4
+
5
+ __all__ = [
6
+ "__version__",
7
+ "__version_tuple__",
8
+ "version",
9
+ "version_tuple",
10
+ "__commit_id__",
11
+ "commit_id",
12
+ ]
13
+
14
+ version: str
15
+ __version__: str
16
+ __version_tuple__: tuple[int | str, ...]
17
+ version_tuple: tuple[int | str, ...]
18
+ commit_id: str | None
19
+ __commit_id__: str | None
20
+
21
+ __version__ = version = '1.0.0'
22
+ __version_tuple__ = version_tuple = (1, 0, 0)
23
+
24
+ __commit_id__ = commit_id = 'ge2f9626cc'