sqlServerConnector 0.1.10__tar.gz → 0.1.11__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.4
2
2
  Name: sqlServerConnector
3
- Version: 0.1.10
3
+ Version: 0.1.11
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
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
6
6
 
7
7
  [project]
8
8
  name = "sqlServerConnector"
9
- version = "0.1.10"
9
+ version = "0.1.11"
10
10
  description = "A custom SQL Server Connector for ETL processes with Pandas"
11
11
  readme = "README.md"
12
12
  requires-python = ">=3.8"
@@ -253,6 +253,14 @@ class SQLServerConnector:
253
253
 
254
254
  if not join_keys:
255
255
  logger.warning(f"No keys provided for {target_table}. Switching to APPEND mode.")
256
+ else:
257
+ # --- CRITICAL FIX FOR UNIQUE KEY VIOLATION ---
258
+ # Remove duplicates in Python before sending to Staging Table
259
+ # This prevents MERGE from crashing when Source has duplicate keys
260
+ initial_count = len(df)
261
+ df = df.drop_duplicates(subset=join_keys, keep='last').copy()
262
+ if len(df) < initial_count:
263
+ logger.warning(f"Dropped {initial_count - len(df)} duplicate rows based on keys {join_keys} before upsert.")
256
264
 
257
265
  # 2. Xử lý Logic 'SUM' (Aggregation tại Python trước khi đẩy DB)
258
266
  # Đây là logic quý giá từ code cũ của bạn
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sqlServerConnector
3
- Version: 0.1.10
3
+ Version: 0.1.11
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