sqlServerConnector 0.1.12__tar.gz → 0.1.14__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.
- {sqlserverconnector-0.1.12 → sqlserverconnector-0.1.14}/PKG-INFO +1 -1
- {sqlserverconnector-0.1.12 → sqlserverconnector-0.1.14}/pyproject.toml +1 -1
- {sqlserverconnector-0.1.12 → sqlserverconnector-0.1.14}/src/connector.py +25 -3
- {sqlserverconnector-0.1.12 → sqlserverconnector-0.1.14}/src/sqlServerConnector.egg-info/PKG-INFO +1 -1
- {sqlserverconnector-0.1.12 → sqlserverconnector-0.1.14}/README.md +0 -0
- {sqlserverconnector-0.1.12 → sqlserverconnector-0.1.14}/setup.cfg +0 -0
- {sqlserverconnector-0.1.12 → sqlserverconnector-0.1.14}/src/__init__.py +0 -0
- {sqlserverconnector-0.1.12 → sqlserverconnector-0.1.14}/src/sqlServerConnector.egg-info/SOURCES.txt +0 -0
- {sqlserverconnector-0.1.12 → sqlserverconnector-0.1.14}/src/sqlServerConnector.egg-info/dependency_links.txt +0 -0
- {sqlserverconnector-0.1.12 → sqlserverconnector-0.1.14}/src/sqlServerConnector.egg-info/requires.txt +0 -0
- {sqlserverconnector-0.1.12 → sqlserverconnector-0.1.14}/src/sqlServerConnector.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sqlServerConnector
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.14
|
|
4
4
|
Summary: A custom SQL Server Connector for ETL processes with Pandas
|
|
5
5
|
Author-email: Nguyen Minh Son <nguyen.minhson1511@gmail.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/johnnyb1509/sqlServerConnector
|
|
@@ -220,7 +220,7 @@ class SQLServerConnector:
|
|
|
220
220
|
conn.execute(text(f"ALTER TABLE [{table_name}] ADD [{col}] {type_str}"))
|
|
221
221
|
logger.info(f"Auto-evolve: Added column '{col}' to table '{table_name}'")
|
|
222
222
|
|
|
223
|
-
def upsert_data(self,
|
|
223
|
+
def upsert_data(self,
|
|
224
224
|
df: pd.DataFrame,
|
|
225
225
|
target_table: str,
|
|
226
226
|
primary_key: Union[str, List[str]] = None,
|
|
@@ -233,6 +233,8 @@ def upsert_data(self,
|
|
|
233
233
|
"""
|
|
234
234
|
if df.empty:
|
|
235
235
|
return
|
|
236
|
+
|
|
237
|
+
df = self._sanitize_data(df)
|
|
236
238
|
|
|
237
239
|
# 1. Xác định Join Keys
|
|
238
240
|
join_keys = match_columns or (
|
|
@@ -367,8 +369,28 @@ def upsert_data(self,
|
|
|
367
369
|
except Exception:
|
|
368
370
|
pass
|
|
369
371
|
|
|
370
|
-
def
|
|
371
|
-
|
|
372
|
+
def _sanitize_data(self, df: pd.DataFrame) -> pd.DataFrame:
|
|
373
|
+
"""
|
|
374
|
+
Sanitizes DataFrame before SQL upload.
|
|
375
|
+
Forces Pandas Timestamps into Pure Python datetime objects to
|
|
376
|
+
safely pass through pyodbc's fast_executemany without overflow.
|
|
377
|
+
"""
|
|
378
|
+
df_clean = df.copy()
|
|
379
|
+
|
|
380
|
+
for col in df_clean.columns:
|
|
381
|
+
# Check if the column is a datetime type
|
|
382
|
+
if pd.api.types.is_datetime64_any_dtype(df_clean[col]):
|
|
383
|
+
# 1. Floor to nearest second to avoid DB precision issues
|
|
384
|
+
floored_series = df_clean[col].dt.floor('s')
|
|
385
|
+
|
|
386
|
+
# 2. CRITICAL FIX: Convert Pandas Timestamp -> Pure Python datetime
|
|
387
|
+
# (and cleanly handle NaT/NaN as None)
|
|
388
|
+
df_clean[col] = [
|
|
389
|
+
x.to_pydatetime() if pd.notna(x) else None
|
|
390
|
+
for x in floored_series
|
|
391
|
+
]
|
|
392
|
+
|
|
393
|
+
return df_clean
|
|
372
394
|
|
|
373
395
|
def dispose(self):
|
|
374
396
|
self.engine.dispose()
|
{sqlserverconnector-0.1.12 → sqlserverconnector-0.1.14}/src/sqlServerConnector.egg-info/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sqlServerConnector
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.14
|
|
4
4
|
Summary: A custom SQL Server Connector for ETL processes with Pandas
|
|
5
5
|
Author-email: Nguyen Minh Son <nguyen.minhson1511@gmail.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/johnnyb1509/sqlServerConnector
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sqlserverconnector-0.1.12 → sqlserverconnector-0.1.14}/src/sqlServerConnector.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{sqlserverconnector-0.1.12 → sqlserverconnector-0.1.14}/src/sqlServerConnector.egg-info/requires.txt
RENAMED
|
File without changes
|
|
File without changes
|