pjdev-sqlmodel 3.4.2__tar.gz → 3.4.2a3__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.
- {pjdev_sqlmodel-3.4.2 → pjdev_sqlmodel-3.4.2a3}/PKG-INFO +3 -1
- {pjdev_sqlmodel-3.4.2 → pjdev_sqlmodel-3.4.2a3}/pyproject.toml +2 -0
- {pjdev_sqlmodel-3.4.2 → pjdev_sqlmodel-3.4.2a3}/src/pjdev_sqlmodel/__about__.py +1 -1
- {pjdev_sqlmodel-3.4.2 → pjdev_sqlmodel-3.4.2a3}/src/pjdev_sqlmodel/utilities.py +28 -16
- {pjdev_sqlmodel-3.4.2 → pjdev_sqlmodel-3.4.2a3}/.gitignore +0 -0
- {pjdev_sqlmodel-3.4.2 → pjdev_sqlmodel-3.4.2a3}/LICENSE.txt +0 -0
- {pjdev_sqlmodel-3.4.2 → pjdev_sqlmodel-3.4.2a3}/README.md +0 -0
- {pjdev_sqlmodel-3.4.2 → pjdev_sqlmodel-3.4.2a3}/src/pjdev_sqlmodel/__init__.py +0 -0
- {pjdev_sqlmodel-3.4.2 → pjdev_sqlmodel-3.4.2a3}/src/pjdev_sqlmodel/db_models.py +0 -0
- {pjdev_sqlmodel-3.4.2 → pjdev_sqlmodel-3.4.2a3}/src/pjdev_sqlmodel/service.py +0 -0
- {pjdev_sqlmodel-3.4.2 → pjdev_sqlmodel-3.4.2a3}/src/pjdev_sqlmodel/settings.py +0 -0
- {pjdev_sqlmodel-3.4.2 → pjdev_sqlmodel-3.4.2a3}/tests/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: pjdev-sqlmodel
|
|
3
|
-
Version: 3.4.
|
|
3
|
+
Version: 3.4.2a3
|
|
4
4
|
Project-URL: Documentation, https://gitlab.purplejay.net/keystone/python
|
|
5
5
|
Project-URL: Issues, https://gitlab.purplejay.net/keystone/python/issues
|
|
6
6
|
Project-URL: Source, https://gitlab.purplejay.net/keystone/python
|
|
@@ -16,7 +16,9 @@ Requires-Python: >=3.12
|
|
|
16
16
|
Requires-Dist: loguru
|
|
17
17
|
Requires-Dist: openpyxl>=3.1.5
|
|
18
18
|
Requires-Dist: pandas>=2.2.2
|
|
19
|
+
Requires-Dist: pyarrow>=17.0.0
|
|
19
20
|
Requires-Dist: pydantic-settings>=2.3.4
|
|
21
|
+
Requires-Dist: python-calamine>=0.2.3
|
|
20
22
|
Requires-Dist: sqlmodel>=0.0.19
|
|
21
23
|
Description-Content-Type: text/markdown
|
|
22
24
|
|
|
@@ -58,14 +58,8 @@ def load_csv_data(model_type: Type[T], data_files: List[Path]) -> None:
|
|
|
58
58
|
|
|
59
59
|
data: List[model_type] = []
|
|
60
60
|
for file in filtered_files:
|
|
61
|
-
df =
|
|
62
|
-
|
|
63
|
-
try:
|
|
64
|
-
for _, row in df.iterrows():
|
|
65
|
-
d = model_type.model_validate(row.to_dict())
|
|
66
|
-
data.append(d)
|
|
67
|
-
except ValidationError as e:
|
|
68
|
-
logger.error(f"Error when parsing {file.name}: {e}")
|
|
61
|
+
df = __read_csv(file, cols)
|
|
62
|
+
data.extend(__convert_to_models(file.name, df, model_type))
|
|
69
63
|
|
|
70
64
|
with session_context() as session:
|
|
71
65
|
session.add_all(data)
|
|
@@ -106,14 +100,8 @@ def load_excel_data(
|
|
|
106
100
|
)
|
|
107
101
|
|
|
108
102
|
for file in filtered_files:
|
|
109
|
-
df =
|
|
110
|
-
|
|
111
|
-
try:
|
|
112
|
-
for _, row in df.iterrows():
|
|
113
|
-
d = model_type.model_validate(row.to_dict())
|
|
114
|
-
data.append(d)
|
|
115
|
-
except ValidationError as e:
|
|
116
|
-
logger.error(f"Error when parsing {file.name}: {e}")
|
|
103
|
+
df = __read_excel(file, cols, header_ndx)
|
|
104
|
+
data.extend(__convert_to_models(file.name, df, model_type))
|
|
117
105
|
|
|
118
106
|
with session_context() as session:
|
|
119
107
|
session.add_all(data)
|
|
@@ -121,6 +109,30 @@ def load_excel_data(
|
|
|
121
109
|
logger.info("Loaded {} rows for {} table".format(len(data), model_type.__name__))
|
|
122
110
|
|
|
123
111
|
|
|
112
|
+
def __convert_to_models(
|
|
113
|
+
filename: str, df: pd.DataFrame, model_type: Type[T]
|
|
114
|
+
) -> List[T]:
|
|
115
|
+
data: List[model_type] = []
|
|
116
|
+
try:
|
|
117
|
+
for _, row in df.iterrows():
|
|
118
|
+
d = model_type.model_validate(row.to_dict())
|
|
119
|
+
data.append(d)
|
|
120
|
+
except ValidationError as e:
|
|
121
|
+
logger.error(f"Error when parsing {filename}: {e}")
|
|
122
|
+
|
|
123
|
+
return data
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def __read_csv(file, cols) -> pd.DataFrame:
|
|
127
|
+
return pd.read_csv(file, engine="pyarrow", usecols=cols, na_filter=False)
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def __read_excel(file, cols, header_ndx) -> pd.DataFrame:
|
|
131
|
+
return pd.read_excel(
|
|
132
|
+
io=file, usecols=cols, na_filter=False, header=header_ndx, engine="calamine"
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
|
|
124
136
|
def convert_to_csv(
|
|
125
137
|
data: List[BaseModel],
|
|
126
138
|
col_mapping_tuple: Tuple[List[str], Dict[str, str], List[str]],
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|