f3-data-models 0.4.4__tar.gz → 0.4.6__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: f3-data-models
3
- Version: 0.4.4
3
+ Version: 0.4.6
4
4
  Summary: The data schema and models for F3 Nation applications.
5
5
  License: MIT
6
6
  Author: Evan Petzoldt
@@ -0,0 +1,27 @@
1
+ from f3_data_models.models import Location
2
+ from f3_data_models.utils import DbManager
3
+
4
+
5
+ def test_update_event():
6
+ DbManager.update_record(
7
+ Location,
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
+ )
24
+
25
+
26
+ if __name__ == "__main__":
27
+ test_update_event()
@@ -10,7 +10,6 @@ from sqlalchemy import Select, and_, inspect, select
10
10
  from sqlalchemy.dialects.postgresql import insert
11
11
  from sqlalchemy.engine import Engine
12
12
  from sqlalchemy.orm import class_mapper, joinedload, sessionmaker
13
- from sqlalchemy.orm.attributes import InstrumentedAttribute
14
13
  from sqlalchemy.orm.collections import InstrumentedList
15
14
  from sqlalchemy_schemadisplay import create_schema_graph
16
15
 
@@ -158,9 +157,13 @@ class DbManager:
158
157
  relationships = mapper.relationships.keys()
159
158
  for attr, value in fields.items():
160
159
  key = attr if isinstance(attr, str) else attr.key
160
+ print(f"key: {key}, value: {value}")
161
161
  if hasattr(cls, key) and key not in relationships:
162
- if isinstance(attr, InstrumentedAttribute):
163
- setattr(record, key, value)
162
+ setattr(record, key, value)
163
+ # if isinstance(attr, InstrumentedAttribute):
164
+ # setattr(record, key, value)
165
+ # else:
166
+ # setattr(record, key, value)
164
167
  elif key in relationships:
165
168
  # Handle relationships separately
166
169
  relationship = mapper.relationships[key]
@@ -189,6 +192,7 @@ class DbManager:
189
192
  session.add(related_record)
190
193
 
191
194
  try:
195
+ print(record)
192
196
  session.commit()
193
197
  except pg8000.IntegrityError as e:
194
198
  session.rollback()
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "f3-data-models"
3
- version = "0.4.4"
3
+ version = "0.4.6"
4
4
  description = "The data schema and models for F3 Nation applications."
5
5
  authors = ["Evan Petzoldt <evan.petzoldt@protonmail.com>"]
6
6
  readme = "README.md"
@@ -1,13 +0,0 @@
1
- from f3_data_models.models import User
2
- from f3_data_models.utils import DbManager
3
-
4
-
5
- def test_update_event():
6
- user = User(
7
- email="evan.Petzoldt@protonmail.com",
8
- )
9
- DbManager.create_record(user)
10
-
11
-
12
- if __name__ == "__main__":
13
- test_update_event()
File without changes