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

velocity/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
- __version__ = version = "0.0.146"
1
+ __version__ = version = "0.0.148"
2
2
 
3
3
  from . import aws
4
4
  from . import db
velocity/db/core/table.py CHANGED
@@ -1,5 +1,5 @@
1
1
  import sqlparse
2
- from collections.abc import Mapping
2
+ from collections.abc import Iterable, Mapping
3
3
  from velocity.db import exceptions
4
4
  from velocity.db.core.row import Row
5
5
  from velocity.db.core.result import Result
@@ -120,6 +120,59 @@ class Table:
120
120
  return sql, vals
121
121
  self.tx.execute(sql, vals, cursor=self.cursor())
122
122
 
123
+ def create_indexes(self, indexes, **kwds):
124
+ """
125
+ Convenience wrapper to create multiple indexes in order.
126
+
127
+ Accepts an iterable of definitions. Each definition may be either:
128
+ - Mapping with a required "columns" entry plus optional "unique",
129
+ "direction", "where", and "lower" keys.
130
+ - A simple sequence/string of columns, in which case defaults apply.
131
+
132
+ When sql_only=True, a list of (sql, params) tuples is returned.
133
+ """
134
+
135
+ if indexes is None:
136
+ return [] if kwds.get("sql_only", False) else None
137
+
138
+ if not isinstance(indexes, Iterable) or isinstance(indexes, (str, bytes)):
139
+ raise TypeError("indexes must be an iterable of index definitions")
140
+
141
+ sql_only = kwds.get("sql_only", False)
142
+ statements = []
143
+
144
+ for definition in indexes:
145
+ if isinstance(definition, Mapping):
146
+ columns = definition.get("columns")
147
+ if not columns:
148
+ raise ValueError("Index definition requires a non-empty 'columns' entry")
149
+ params = {
150
+ "unique": definition.get("unique", False),
151
+ "direction": definition.get("direction"),
152
+ "where": definition.get("where"),
153
+ "lower": definition.get("lower"),
154
+ }
155
+ else:
156
+ columns = definition
157
+ params = {
158
+ "unique": False,
159
+ "direction": None,
160
+ "where": None,
161
+ "lower": None,
162
+ }
163
+
164
+ if isinstance(columns, str):
165
+ columns = [columns]
166
+
167
+ if not columns:
168
+ raise ValueError("Index columns cannot be empty")
169
+
170
+ result = self.create_index(columns, **params, **kwds)
171
+ if sql_only:
172
+ statements.append(result)
173
+
174
+ return statements if sql_only else None
175
+
123
176
  @return_default(None)
124
177
  def drop_index(self, columns, **kwds):
125
178
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: velocity-python
3
- Version: 0.0.146
3
+ Version: 0.0.148
4
4
  Summary: A rapid application development library for interfacing with data storage
5
5
  Author-email: Velocity Team <info@codeclubs.org>
6
6
  License-Expression: MIT
@@ -1,4 +1,4 @@
1
- velocity/__init__.py,sha256=eTHbtySkoZwrKGo7-cejLeYBrazqLmWV7p4I7p5updo,147
1
+ velocity/__init__.py,sha256=O3HSM_LgXBV4_mGkZ13G76l0LMcYjcRWPSa5t3uXN6k,147
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=fr1oTBjSFfyeMBUXRG06LV4jgwrlwYNL5mbEBleFwf0,6328
@@ -37,7 +37,7 @@ velocity/db/core/engine.py,sha256=mNlaFPruHO935phKPVrsxZprGYUvxW-zp2sBcBZ-KCg,20
37
37
  velocity/db/core/result.py,sha256=b0ie3yZAOj9S57x32uFFGKZ95zhImmZ0iXl0X1qYszc,12813
38
38
  velocity/db/core/row.py,sha256=yqxm03uEDy3oSbnkCtKyiqFdSqG3zXTq2HIHYKOvPY4,7291
39
39
  velocity/db/core/sequence.py,sha256=VMBc0ZjGnOaWTwKW6xMNTdP8rZ2umQ8ml4fHTTwuGq4,3904
40
- velocity/db/core/table.py,sha256=1sgR0bKO-6aZ2tmv9P9TGck5WrBiGErYqqRFKKIObsI,39964
40
+ velocity/db/core/table.py,sha256=6g0eHYZX9VU681kKtdEAzI_sW4Ag4IGesmEHRFJN7N4,41931
41
41
  velocity/db/core/transaction.py,sha256=unjmVkkfb7D8Wow6V8V8aLaxUZo316i--ksZxc4-I1Q,6613
42
42
  velocity/db/servers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
43
43
  velocity/db/servers/tablehelper.py,sha256=Q48ObN5KD_U2sBP0GUcjaQjKeE4Hr351sPQirwQ0_1s,22163
@@ -122,8 +122,8 @@ velocity/misc/tests/test_merge.py,sha256=Vm5_jY5cVczw0hZF-3TYzmxFw81heJOJB-dvhCg
122
122
  velocity/misc/tests/test_oconv.py,sha256=fy4DwWGn_v486r2d_3ACpuBD-K1oOngNq1HJCGH7X-M,4694
123
123
  velocity/misc/tests/test_original_error.py,sha256=iWSd18tckOA54LoPQOGV5j9LAz2W-3_ZOwmyZ8-4YQc,1742
124
124
  velocity/misc/tests/test_timer.py,sha256=l9nrF84kHaFofvQYKInJmfoqC01wBhsUB18lVBgXCoo,2758
125
- velocity_python-0.0.146.dist-info/licenses/LICENSE,sha256=aoN245GG8s9oRUU89KNiGTU4_4OtnNmVi4hQeChg6rM,1076
126
- velocity_python-0.0.146.dist-info/METADATA,sha256=k6_Iu7vrWLlQQpgVFw09S7hAKJtLSzuUFAU-3BcM7V8,34262
127
- velocity_python-0.0.146.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
128
- velocity_python-0.0.146.dist-info/top_level.txt,sha256=JW2vJPmodgdgSz7H6yoZvnxF8S3fTMIv-YJWCT1sNW0,9
129
- velocity_python-0.0.146.dist-info/RECORD,,
125
+ velocity_python-0.0.148.dist-info/licenses/LICENSE,sha256=aoN245GG8s9oRUU89KNiGTU4_4OtnNmVi4hQeChg6rM,1076
126
+ velocity_python-0.0.148.dist-info/METADATA,sha256=dLYjKtxZOckMF9adXMhUGpyOoZ0kL4dNqTMSYmO4aBA,34262
127
+ velocity_python-0.0.148.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
128
+ velocity_python-0.0.148.dist-info/top_level.txt,sha256=JW2vJPmodgdgSz7H6yoZvnxF8S3fTMIv-YJWCT1sNW0,9
129
+ velocity_python-0.0.148.dist-info/RECORD,,