velocity-python 0.0.93__py3-none-any.whl → 0.0.95__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.

Potentially problematic release.


This version of velocity-python might be problematic. Click here for more details.

@@ -1,4 +1,4 @@
1
- velocity/__init__.py,sha256=SXXkM3wd93I5MId7dRstfGcdJMM5OWzxrAlf4r1Smh0,106
1
+ velocity/__init__.py,sha256=Ia6_qjrZBVx6x83-y9sI4W7UBXzNOKPSIofuJb7lVrk,106
2
2
  velocity/app/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  velocity/app/invoices.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  velocity/app/orders.py,sha256=W-HAXEwY8-IFXbKh82HnMeRVZM7P-TWGEQOWtkLIzI4,6298
@@ -30,11 +30,11 @@ velocity/db/servers/sqlite.py,sha256=X210a5pENT9PiVK7f16fxXzFwEsq8fSe58Vouv2xqlk
30
30
  velocity/db/servers/sqlite_reserved.py,sha256=-xmjl-Hgu6lKqkCAXq_6U8_aJX6gvaMgLMLdCt-Ej7o,3006
31
31
  velocity/db/servers/sqlserver.py,sha256=0uGLEWRXiUhrOVTpEA1zvaKq1mcfiaCDp9r7gX-N71g,29914
32
32
  velocity/db/servers/sqlserver_reserved.py,sha256=3LGQYU0qfvk6AbKety96gbzzfLbZ0dNHDPLxKGvvi4Q,4596
33
- velocity/db/servers/tablehelper.py,sha256=IW17pedialg2xNORv2uAqNA9SB3aomDtB1HRxAEvBmA,21936
34
- velocity/db/servers/postgres/__init__.py,sha256=Z0zJib46hz1zfEAMG0rQBlJ6lp47LW7t0_63xMS0zrI,528
33
+ velocity/db/servers/tablehelper.py,sha256=S_759UBIqj-xn6IzwIu6wU7QSrUdLtg0-T80j23m23Y,22016
34
+ velocity/db/servers/postgres/__init__.py,sha256=FUvXO3R5CtKCTGRim1geisIxXbiG_aQ_VFSQX9HGsjw,529
35
35
  velocity/db/servers/postgres/operators.py,sha256=A2T1qFwhzPl0fdXVhLZJhh5Qfx-qF8oZsDnxnq2n_V8,389
36
36
  velocity/db/servers/postgres/reserved.py,sha256=5tKLaqFV-HrWRj-nsrxl5KGbmeM3ukn_bPZK36XEu8M,3648
37
- velocity/db/servers/postgres/sql.py,sha256=OoVctgZ3C2sUu6PeMFVCbmQHyfWY-KNmBlCX2PkvaGA,41326
37
+ velocity/db/servers/postgres/sql.py,sha256=dDUcdErrAgWulrr6582p4Zf1co6-PH8MfVU2q9KRisI,41416
38
38
  velocity/db/servers/postgres/types.py,sha256=Wa45ppVf_pdWul-jYWFRGMl6IdSq8dAp10SKnhL7osQ,3757
39
39
  velocity/misc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
40
40
  velocity/misc/db.py,sha256=MPgt-kkukKR_Wh_S_5W-MyDgaeoZ4YLoDJ54wU2ppm4,2830
@@ -47,8 +47,8 @@ velocity/misc/tools.py,sha256=_bGneHHA_BV-kUonzw5H3hdJ5AOJRCKfzhgpkFbGqIo,1502
47
47
  velocity/misc/conv/__init__.py,sha256=MLYF58QHjzfDSxb1rdnmLnuEQCa3gnhzzZ30CwZVvQo,40
48
48
  velocity/misc/conv/iconv.py,sha256=d4_BucW8HTIkGNurJ7GWrtuptqUf-9t79ObzjJ5N76U,10603
49
49
  velocity/misc/conv/oconv.py,sha256=h5Lo05DqOQnxoD3y6Px_MQP_V-pBbWf8Hkgkb9Xp1jk,6032
50
- velocity_python-0.0.93.dist-info/licenses/LICENSE,sha256=aoN245GG8s9oRUU89KNiGTU4_4OtnNmVi4hQeChg6rM,1076
51
- velocity_python-0.0.93.dist-info/METADATA,sha256=7jiOZpb90Inx1hJFYZ_snU4tnF2Wk13_f2s95SbDhw8,10634
52
- velocity_python-0.0.93.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
53
- velocity_python-0.0.93.dist-info/top_level.txt,sha256=JW2vJPmodgdgSz7H6yoZvnxF8S3fTMIv-YJWCT1sNW0,9
54
- velocity_python-0.0.93.dist-info/RECORD,,
50
+ velocity_python-0.0.95.dist-info/licenses/LICENSE,sha256=aoN245GG8s9oRUU89KNiGTU4_4OtnNmVi4hQeChg6rM,1076
51
+ velocity_python-0.0.95.dist-info/METADATA,sha256=0ve_k4tFITuVudvOEsARj3hIPyuaAhTCEWXhTiTUA3g,33022
52
+ velocity_python-0.0.95.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
53
+ velocity_python-0.0.95.dist-info/top_level.txt,sha256=JW2vJPmodgdgSz7H6yoZvnxF8S3fTMIv-YJWCT1sNW0,9
54
+ velocity_python-0.0.95.dist-info/RECORD,,
@@ -1,423 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: velocity-python
3
- Version: 0.0.93
4
- Summary: A rapid application development library for interfacing with data storage
5
- Author-email: Velocity Team <contact@example.com>
6
- License: MIT
7
- Project-URL: Homepage, https://codeclubs.org/projects/velocity
8
- Keywords: database,orm,sql,rapid-development,data-storage
9
- Classifier: Development Status :: 3 - Alpha
10
- Classifier: Intended Audience :: Developers
11
- Classifier: Topic :: Database
12
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
13
- Classifier: Programming Language :: Python :: 3
14
- Classifier: Programming Language :: Python :: 3.7
15
- Classifier: Programming Language :: Python :: 3.8
16
- Classifier: Programming Language :: Python :: 3.9
17
- Classifier: Programming Language :: Python :: 3.10
18
- Classifier: Programming Language :: Python :: 3.11
19
- Classifier: License :: OSI Approved :: MIT License
20
- Classifier: Operating System :: OS Independent
21
- Requires-Python: >=3.7
22
- Description-Content-Type: text/markdown
23
- License-File: LICENSE
24
- Requires-Dist: boto3>=1.26.0
25
- Requires-Dist: requests>=2.25.0
26
- Requires-Dist: jinja2>=3.0.0
27
- Requires-Dist: xlrd>=2.0.0
28
- Requires-Dist: openpyxl>=3.0.0
29
- Requires-Dist: sqlparse>=0.4.0
30
- Provides-Extra: mysql
31
- Requires-Dist: mysql-connector-python>=8.0.0; extra == "mysql"
32
- Provides-Extra: sqlserver
33
- Requires-Dist: python-tds>=1.10.0; extra == "sqlserver"
34
- Provides-Extra: postgres
35
- Requires-Dist: psycopg2-binary>=2.9.0; extra == "postgres"
36
- Provides-Extra: dev
37
- Requires-Dist: pytest>=7.0.0; extra == "dev"
38
- Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
39
- Requires-Dist: black>=23.0.0; extra == "dev"
40
- Requires-Dist: flake8>=6.0.0; extra == "dev"
41
- Requires-Dist: mypy>=1.0.0; extra == "dev"
42
- Requires-Dist: pre-commit>=3.0.0; extra == "dev"
43
- Provides-Extra: test
44
- Requires-Dist: pytest>=7.0.0; extra == "test"
45
- Requires-Dist: pytest-cov>=4.0.0; extra == "test"
46
- Requires-Dist: pytest-mock>=3.10.0; extra == "test"
47
- Provides-Extra: docs
48
- Requires-Dist: sphinx>=5.0.0; extra == "docs"
49
- Requires-Dist: sphinx-rtd-theme>=1.2.0; extra == "docs"
50
- Dynamic: license-file
51
-
52
- # Velocity.DB
53
-
54
- A modern Python database abstraction library that simplifies database operations across multiple database engines. Velocity.DB provides a unified interface for PostgreSQL, MySQL, SQLite, and SQL Server, with features like transaction management, automatic connection pooling, and database-agnostic query building.
55
-
56
- ## Features
57
-
58
- - **Multi-database support**: PostgreSQL, MySQL, SQLite, SQL Server
59
- - **Transaction management**: Decorator-based transaction handling with automatic rollback
60
- - **Query builder**: Database-agnostic SQL generation with foreign key expansion
61
- - **Connection pooling**: Automatic connection management and pooling
62
- - **Type safety**: Comprehensive type hints and validation
63
- - **Modern Python**: Built for Python 3.8+ with modern packaging
64
-
65
- ## Supported Databases
66
-
67
- - **PostgreSQL** (via psycopg2)
68
- - **MySQL** (via mysqlclient)
69
- - **SQLite** (built-in sqlite3)
70
- - **SQL Server** (via pytds)
71
-
72
- ## Installation
73
-
74
- Install the base package:
75
-
76
- ```bash
77
- pip install velocity-python
78
- ```
79
-
80
- Install with database-specific dependencies:
81
-
82
- ```bash
83
- # For PostgreSQL
84
- pip install velocity-python[postgres]
85
-
86
- # For MySQL
87
- pip install velocity-python[mysql]
88
-
89
- # For SQL Server
90
- pip install velocity-python[sqlserver]
91
-
92
- # For all databases
93
- pip install velocity-python[all]
94
- ```
95
-
96
- ## Quick Start
97
-
98
- ### Database Connection
99
-
100
- ```python
101
- import velocity.db
102
-
103
- # PostgreSQL
104
- engine = velocity.db.postgres(
105
- host="localhost",
106
- port=5432,
107
- database="mydb",
108
- user="username",
109
- password="password"
110
- )
111
-
112
- # MySQL
113
- engine = velocity.db.mysql(
114
- host="localhost",
115
- port=3306,
116
- database="mydb",
117
- user="username",
118
- password="password"
119
- )
120
-
121
- # SQLite
122
- engine = velocity.db.sqlite("path/to/database.db")
123
-
124
- # SQL Server
125
- engine = velocity.db.sqlserver(
126
- host="localhost",
127
- port=1433,
128
- database="mydb",
129
- user="username",
130
- password="password"
131
- ### Transaction Management
132
-
133
- Use the `@engine.transaction` decorator for automatic transaction handling:
134
-
135
- ```python
136
- @engine.transaction
137
- def create_user(tx):
138
- # All operations within this function are wrapped in a transaction
139
- user = tx.table('users').new()
140
- user['name'] = 'John Doe'
141
- user['email'] = 'john@example.com'
142
- # Transaction commits automatically on success or rolls back on error
143
- return user['sys_id']
144
- ```
145
-
146
- ### Table Operations
147
-
148
- #### Creating Tables
149
-
150
- ```python
151
- @engine.transaction
152
- def create_tables(tx):
153
- # Create a users table
154
- users = tx.table('users')
155
- users.create()
156
-
157
- # Add columns by setting data
158
- user = users.new()
159
- user['name'] = 'Sample User'
160
- user['email'] = 'user@example.com'
161
- user['created_at'] = datetime.now()
162
- ```
163
-
164
- #### Selecting Data
165
-
166
- ```python
167
- @engine.transaction
168
- def query_users(tx):
169
- users = tx.table('users')
170
-
171
- # Select all users
172
- all_users = users.select().all()
173
-
174
- # Select with conditions
175
- active_users = users.select(where={'status': 'active'}).all()
176
-
177
- # Select specific columns
178
- names = users.select(columns=['name', 'email']).all()
179
-
180
- # Select with ordering and limits
181
- recent = users.select(
182
- orderby='created_at DESC',
183
- qty=10
184
- ).all()
185
-
186
- # Find single record
187
- user = users.find({'email': 'john@example.com'})
188
-
189
- # Get by primary key
190
- user = users.find(123)
191
- ```
192
-
193
- #### Updating Data
194
-
195
- ```python
196
- @engine.transaction
197
- def update_user(tx):
198
- users = tx.table('users')
199
-
200
- # Update single record
201
- user = users.find(123)
202
- user['name'] = 'Updated Name'
203
- user['updated_at'] = datetime.now()
204
-
205
- # Bulk update
206
- users.update(
207
- {'status': 'inactive'},
208
- where={'<last_login': '2023-01-01'}
209
- )
210
- ```
211
-
212
- #### Inserting Data
213
-
214
- ```python
215
- @engine.transaction
216
- def create_users(tx):
217
- users = tx.table('users')
218
-
219
- # Create new record
220
- user = users.new()
221
- user['name'] = 'New User'
222
- user['email'] = 'new@example.com'
223
-
224
- # Insert with data
225
- user_id = users.insert({
226
- 'name': 'Another User',
227
- 'email': 'another@example.com'
228
- })
229
-
230
- # Upsert (insert or update)
231
- users.upsert(
232
- {'name': 'John Doe', 'status': 'active'},
233
- {'email': 'john@example.com'} # matching condition
234
- )
235
- ```
236
-
237
- #### Deleting Data
238
-
239
- ```python
240
- @engine.transaction
241
- def delete_users(tx):
242
- users = tx.table('users')
243
-
244
- # Delete single record
245
- user = users.find(123)
246
- user.delete()
247
-
248
- # Delete with conditions
249
- users.delete(where={'status': 'inactive'})
250
-
251
- # Truncate table
252
- users.truncate()
253
-
254
- # Drop table
255
- users.drop()
256
- ```
257
-
258
- ### Advanced Queries
259
-
260
- #### Foreign Key Navigation
261
-
262
- Velocity.DB supports automatic foreign key expansion using pointer syntax:
263
-
264
- ```python
265
- @engine.transaction
266
- def get_user_with_profile(tx):
267
- users = tx.table('users')
268
-
269
- # Automatic join via foreign key
270
- users_with_profiles = users.select(
271
- columns=['name', 'email', 'profile_id>bio', 'profile_id>avatar_url'],
272
- where={'status': 'active'}
273
- ).all()
274
- ```
275
-
276
- #### Complex Conditions
277
-
278
- Velocity.DB supports various where clause formats:
279
-
280
- ```python
281
- @engine.transaction
282
- def complex_queries(tx):
283
- users = tx.table('users')
284
-
285
- # Dictionary format with operator prefixes
286
- results = users.select(where={
287
- 'status': 'active', # Equals (default)
288
- '>=created_at': '2023-01-01', # Greater than or equal
289
- '><age': [18, 65], # Between
290
- '%email': '@company.com', # Like
291
- '!status': 'deleted' # Not equal
292
- }).all()
293
-
294
- # List of tuples format for complex predicates
295
- results = users.select(where=[
296
- ('status = %s', 'active'),
297
- ('priority = %s OR urgency = %s', ('high', 'critical'))
298
- ]).all()
299
-
300
- # Raw string format
301
- results = users.select(where="status = 'active' AND age >= 18").all()
302
- ```
303
-
304
- **Available Operators:**
305
- - `=` (default): `{'name': 'John'}`
306
- - `>`, `<`, `>=`, `<=`: `{'>age': 18}`, `{'<=score': 100}`
307
- - `!`, `!=`, `<>`: `{'!status': 'deleted'}`
308
- - `%`, `LIKE`: `{'%email': '@company.com'}`
309
- - `!%`, `NOT LIKE`: `{'!%name': 'test%'}`
310
- - `><`, `BETWEEN`: `{'><age': [18, 65]}`
311
- - `!><`, `NOT BETWEEN`: `{'!><score': [0, 50]}`
312
- ```
313
-
314
- #### Aggregations and Grouping
315
-
316
- ```python
317
- @engine.transaction
318
- def analytics(tx):
319
- orders = tx.table('orders')
320
-
321
- # Count records
322
- total_orders = orders.count()
323
- recent_orders = orders.count(where={'>=created_at': '2023-01-01'})
324
-
325
- # Aggregations
326
- stats = orders.select(
327
- columns=['COUNT(*) as total', 'SUM(amount) as revenue', 'AVG(amount) as avg_order'],
328
- where={'status': 'completed'},
329
- groupby='customer_id'
330
- ).all()
331
- ```
332
-
333
- ### Raw SQL
334
-
335
- When you need full control, execute raw SQL:
336
-
337
- ```python
338
- @engine.transaction
339
- def raw_queries(tx):
340
- # Execute raw SQL
341
- results = tx.execute("""
342
- SELECT u.name, COUNT(o.id) as order_count
343
- FROM users u
344
- LEFT JOIN orders o ON u.id = o.user_id
345
- WHERE u.status = %s
346
- GROUP BY u.id, u.name
347
- HAVING COUNT(o.id) > %s
348
- """, ['active', 5]).all()
349
-
350
- # Get single value
351
- total = tx.execute("SELECT COUNT(*) FROM users").scalar()
352
-
353
- # Get simple list
354
- names = tx.execute("SELECT name FROM users").as_simple_list()
355
- ```
356
-
357
- ## Error Handling
358
-
359
- Transactions automatically handle rollbacks on exceptions:
360
-
361
- ```python
362
- @engine.transaction
363
- def safe_transfer(tx):
364
- try:
365
- # Multiple operations that must succeed together
366
- from_account = tx.table('accounts').find(from_id)
367
- to_account = tx.table('accounts').find(to_id)
368
-
369
- from_account['balance'] -= amount
370
- to_account['balance'] += amount
371
-
372
- # If any operation fails, entire transaction rolls back
373
-
374
- except Exception as e:
375
- # Transaction automatically rolled back
376
- logger.error(f"Transfer failed: {e}")
377
- raise
378
- ```
379
-
380
- ## Development
381
-
382
- ### Setting up for Development
383
-
384
- ```bash
385
- git clone https://github.com/your-repo/velocity-python.git
386
- cd velocity-python
387
- pip install -e .[dev]
388
- ```
389
-
390
- ### Running Tests
391
-
392
- ```bash
393
- pytest tests/
394
- ```
395
-
396
- ### Code Quality
397
-
398
- ```bash
399
- # Format code
400
- black src/
401
-
402
- # Type checking
403
- mypy src/
404
-
405
- # Linting
406
- flake8 src/
407
- ```
408
-
409
- ## License
410
-
411
- This project is licensed under the MIT License - see the LICENSE file for details.
412
-
413
- ## Contributing
414
-
415
- 1. Fork the repository
416
- 2. Create a feature branch (`git checkout -b feature/amazing-feature`)
417
- 3. Commit your changes (`git commit -m 'Add some amazing feature'`)
418
- 4. Push to the branch (`git push origin feature/amazing-feature`)
419
- 5. Open a Pull Request
420
-
421
- ## Changelog
422
-
423
- See [CHANGELOG.md](CHANGELOG.md) for a list of changes and version history.