f3-data-models 0.5.4__py3-none-any.whl → 0.5.5__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.
- f3_data_models/testing.py +2 -18
- f3_data_models/utils.py +14 -14
- {f3_data_models-0.5.4.dist-info → f3_data_models-0.5.5.dist-info}/METADATA +1 -1
- f3_data_models-0.5.5.dist-info/RECORD +7 -0
- f3_data_models-0.5.4.dist-info/RECORD +0 -7
- {f3_data_models-0.5.4.dist-info → f3_data_models-0.5.5.dist-info}/WHEEL +0 -0
f3_data_models/testing.py
CHANGED
@@ -3,24 +3,8 @@ from f3_data_models.utils import DbManager
|
|
3
3
|
|
4
4
|
|
5
5
|
def test_update_event():
|
6
|
-
DbManager.
|
7
|
-
|
8
|
-
2,
|
9
|
-
{
|
10
|
-
"name": "The Beach",
|
11
|
-
"description": None,
|
12
|
-
"is_active": True,
|
13
|
-
"latitude": 22.0356,
|
14
|
-
"longitude": -159.3377,
|
15
|
-
"address_street": None,
|
16
|
-
"address_street2": None,
|
17
|
-
"address_city": None,
|
18
|
-
"address_state": None,
|
19
|
-
"address_zip": None,
|
20
|
-
"address_country": None,
|
21
|
-
"org_id": 5,
|
22
|
-
},
|
23
|
-
)
|
6
|
+
records = DbManager.find_records(Location, [True])
|
7
|
+
print(records)
|
24
8
|
|
25
9
|
|
26
10
|
if __name__ == "__main__":
|
f3_data_models/utils.py
CHANGED
@@ -88,7 +88,7 @@ def _joinedloads(cls: T, query: Select, joinedloads: list | str = None) -> Selec
|
|
88
88
|
|
89
89
|
|
90
90
|
class DbManager:
|
91
|
-
@
|
91
|
+
@staticmethod
|
92
92
|
def get(cls: Type[T], id: int, joinedloads: list | str = None) -> T:
|
93
93
|
with session_scope() as session:
|
94
94
|
query = select(cls).filter(cls.id == id)
|
@@ -97,7 +97,7 @@ class DbManager:
|
|
97
97
|
session.expunge(record)
|
98
98
|
return record
|
99
99
|
|
100
|
-
@
|
100
|
+
@staticmethod
|
101
101
|
def find_records(cls: T, filters: Optional[List], joinedloads: List | str = None) -> List[T]:
|
102
102
|
with session_scope() as session:
|
103
103
|
query = select(cls)
|
@@ -108,7 +108,7 @@ class DbManager:
|
|
108
108
|
session.expunge(r)
|
109
109
|
return records
|
110
110
|
|
111
|
-
@
|
111
|
+
@staticmethod
|
112
112
|
def find_first_record(cls: T, filters: Optional[List], joinedloads: List | str = None) -> T:
|
113
113
|
with session_scope() as session:
|
114
114
|
query = select(cls)
|
@@ -119,7 +119,7 @@ class DbManager:
|
|
119
119
|
session.expunge(record)
|
120
120
|
return record
|
121
121
|
|
122
|
-
@
|
122
|
+
@staticmethod
|
123
123
|
def find_join_records2(left_cls: T, right_cls: T, filters) -> List[Tuple[T]]:
|
124
124
|
with session_scope() as session:
|
125
125
|
result = session.execute(select(left_cls, right_cls).join(right_cls).filter(and_(*filters)))
|
@@ -127,7 +127,7 @@ class DbManager:
|
|
127
127
|
session.expunge_all()
|
128
128
|
return records
|
129
129
|
|
130
|
-
@
|
130
|
+
@staticmethod
|
131
131
|
def find_join_records3(left_cls: T, right_cls1: T, right_cls2: T, filters, left_join=False) -> List[Tuple[T]]:
|
132
132
|
with session_scope() as session:
|
133
133
|
result = session.execute(
|
@@ -141,7 +141,7 @@ class DbManager:
|
|
141
141
|
session.expunge_all()
|
142
142
|
return records
|
143
143
|
|
144
|
-
@
|
144
|
+
@staticmethod
|
145
145
|
def update_record(cls: T, id, fields):
|
146
146
|
with session_scope() as session:
|
147
147
|
record = session.get(cls, id)
|
@@ -182,7 +182,7 @@ class DbManager:
|
|
182
182
|
related_record = related_class(**{og_primary_key: id, **update_dict})
|
183
183
|
session.add(related_record)
|
184
184
|
|
185
|
-
@
|
185
|
+
@staticmethod
|
186
186
|
def update_records(cls, filters, fields):
|
187
187
|
with session_scope() as session:
|
188
188
|
objects = session.scalars(select(cls).filter(and_(*filters))).all()
|
@@ -232,7 +232,7 @@ class DbManager:
|
|
232
232
|
|
233
233
|
session.flush()
|
234
234
|
|
235
|
-
@
|
235
|
+
@staticmethod
|
236
236
|
def create_record(record: Base) -> Base:
|
237
237
|
with session_scope() as session:
|
238
238
|
session.add(record)
|
@@ -240,7 +240,7 @@ class DbManager:
|
|
240
240
|
session.expunge(record)
|
241
241
|
return record # noqa
|
242
242
|
|
243
|
-
@
|
243
|
+
@staticmethod
|
244
244
|
def create_records(records: List[Base]):
|
245
245
|
with session_scope() as session:
|
246
246
|
session.add_all(records)
|
@@ -248,7 +248,7 @@ class DbManager:
|
|
248
248
|
session.expunge_all()
|
249
249
|
return records # noqa
|
250
250
|
|
251
|
-
@
|
251
|
+
@staticmethod
|
252
252
|
def create_or_ignore(cls: T, records: List[Base]):
|
253
253
|
with session_scope() as session:
|
254
254
|
for record in records:
|
@@ -257,7 +257,7 @@ class DbManager:
|
|
257
257
|
session.execute(stmt)
|
258
258
|
session.flush()
|
259
259
|
|
260
|
-
@
|
260
|
+
@staticmethod
|
261
261
|
def upsert_records(cls, records):
|
262
262
|
with session_scope() as session:
|
263
263
|
for record in records:
|
@@ -271,13 +271,13 @@ class DbManager:
|
|
271
271
|
session.execute(stmt)
|
272
272
|
session.flush()
|
273
273
|
|
274
|
-
@
|
274
|
+
@staticmethod
|
275
275
|
def delete_record(cls: T, id):
|
276
276
|
with session_scope() as session:
|
277
277
|
session.query(cls).filter(cls.id == id).delete()
|
278
278
|
session.flush()
|
279
279
|
|
280
|
-
@
|
280
|
+
@staticmethod
|
281
281
|
def delete_records(cls: T, filters, joinedloads: List | str = None):
|
282
282
|
with session_scope() as session:
|
283
283
|
query = select(cls)
|
@@ -288,7 +288,7 @@ class DbManager:
|
|
288
288
|
session.delete(r)
|
289
289
|
session.flush()
|
290
290
|
|
291
|
-
@
|
291
|
+
@staticmethod
|
292
292
|
def execute_sql_query(sql_query):
|
293
293
|
with session_scope() as session:
|
294
294
|
records = session.execute(sql_query)
|
@@ -0,0 +1,7 @@
|
|
1
|
+
f3_data_models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
+
f3_data_models/models.py,sha256=omQrhckvosTCiYA4uxsx0Wu7hAm69c4MzIVyGq7iWSQ,51523
|
3
|
+
f3_data_models/testing.py,sha256=61-6_uZ99peI_4VInGqTWflxyxF_kzNPW9AQmvrVWco,240
|
4
|
+
f3_data_models/utils.py,sha256=LBNy7BXwRY0tqNKGUBoYi6-1Ch9dSLjGysLoes1Jfys,12083
|
5
|
+
f3_data_models-0.5.5.dist-info/METADATA,sha256=aTlj8od5MtYGICuLN-j16Zx9krObs1-Q_Uglw_BmWW0,2766
|
6
|
+
f3_data_models-0.5.5.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
|
7
|
+
f3_data_models-0.5.5.dist-info/RECORD,,
|
@@ -1,7 +0,0 @@
|
|
1
|
-
f3_data_models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
-
f3_data_models/models.py,sha256=omQrhckvosTCiYA4uxsx0Wu7hAm69c4MzIVyGq7iWSQ,51523
|
3
|
-
f3_data_models/testing.py,sha256=UE88nhMrlflrPqeBM8uHcqCAc_p43q_jsSrPep8f01c,654
|
4
|
-
f3_data_models/utils.py,sha256=IL1JBYitZGWFwn_oWPjM-vOwBcuN2muAk5O4ETyMl_0,12069
|
5
|
-
f3_data_models-0.5.4.dist-info/METADATA,sha256=dcyTBJRtGTac4fl7lzx273a7nECbsx53N-SoVR7Uk6w,2766
|
6
|
-
f3_data_models-0.5.4.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
|
7
|
-
f3_data_models-0.5.4.dist-info/RECORD,,
|
File without changes
|