@@ -659,7 +659,7 @@ def acquire(self, timeout: Optional[float] = 30.0) -> SnowflakeConnection:
659659
660660 return connection
661661 except Empty :
662- raise RuntimeError (f'Failed to acquire connection from pool within { timeout } s' )
662+ raise RuntimeError (f'Failed to acquire connection from pool within { timeout } s' ) from None
663663
664664 def release (self , connection : SnowflakeConnection ) -> None :
665665 """
@@ -772,13 +772,6 @@ def connect(self) -> None:
772772 else :
773773 # Create dedicated connection (legacy behavior)
774774 # Set defaults for connection parameters
775- default_params = {
776- 'login_timeout' : 60 ,
777- 'network_timeout' : 300 ,
778- 'socket_timeout' : 300 ,
779- 'validate_default_parameters' : True ,
780- 'paramstyle' : 'qmark' ,
781- }
782775
783776 conn_params = {
784777 'account' : self .config .account ,
@@ -920,7 +913,7 @@ def _init_streaming_client(self, table_name: str) -> None:
920913 raise ImportError (
921914 'snowpipe-streaming package required for Snowpipe Streaming. '
922915 'Install with: pip install snowpipe-streaming'
923- )
916+ ) from None
924917 except Exception as e :
925918 self .logger .error (f'Failed to initialize Snowpipe Streaming client for { table_name } : { e } ' )
926919 raise
@@ -971,7 +964,8 @@ def _create_streaming_pipe(self, pipe_name: str, table_name: str) -> None:
971964 """
972965 self .cursor .execute (create_pipe_sql )
973966 self .logger .info (
974- f"Created or verified Snowpipe Streaming pipe '{ pipe_name } ' for table { table_name } with { len (column_info )} columns"
967+ f"Created or verified Snowpipe Streaming pipe '{ pipe_name } ' for table { table_name } "
968+ f'with { len (column_info )} columns'
975969 )
976970 except Exception as e :
977971 # Pipe creation might fail if it already exists or if we don't have permissions
@@ -1237,7 +1231,8 @@ def _load_via_stage(self, batch: pa.RecordBatch, table_name: str) -> int:
12371231
12381232 t_end = time .time ()
12391233 self .logger .info (
1240- f'Total _load_via_stage took { t_end - t_start :.2f} s for { rows_loaded } rows ({ rows_loaded / (t_end - t_start ):.0f} rows/sec)'
1234+ f'Total _load_via_stage took { t_end - t_start :.2f} s for { rows_loaded } rows '
1235+ f'({ rows_loaded / (t_end - t_start ):.0f} rows/sec)'
12411236 )
12421237
12431238 return rows_loaded
@@ -1334,7 +1329,7 @@ def _load_via_pandas(self, batch: pa.RecordBatch, table_name: str) -> int:
13341329 raise ImportError (
13351330 'pandas and snowflake.connector.pandas_tools are required for pandas loading. '
13361331 'Install with: pip install pandas'
1337- )
1332+ ) from None
13381333
13391334 t_start = time .time ()
13401335 max_retries = 3 # Retry on transient errors
@@ -1575,7 +1570,10 @@ def _append_with_retry(self, channel: Any, rows: List[Dict[str, Any]]) -> None:
15751570 import sys
15761571
15771572 append_time_ms = (t_append_end - t_append_start ) * 1000
1578- timing_msg = f'⏱️ Snowpipe append: { len (rows )} rows in { append_time_ms :.2f} ms ({ len (rows ) / append_time_ms * 1000 :.0f} rows/sec)\n '
1573+ rows_per_sec = len (rows ) / append_time_ms * 1000
1574+ timing_msg = (
1575+ f'⏱️ Snowpipe append: { len (rows )} rows in { append_time_ms :.2f} ms ({ rows_per_sec :.0f} rows/sec)\n '
1576+ )
15791577 sys .stderr .write (timing_msg )
15801578 sys .stderr .flush ()
15811579
@@ -1649,7 +1647,11 @@ def _load_via_streaming(self, batch: pa.RecordBatch, table_name: str, **kwargs)
16491647 t_batch_end = time .perf_counter ()
16501648 batch_time_ms = (t_batch_end - t_batch_start ) * 1000
16511649 num_chunks = (batch .num_rows + MAX_ROWS_PER_CHUNK - 1 ) // MAX_ROWS_PER_CHUNK
1652- timing_msg = f'⏱️ Batch load complete: { total_loaded } rows in { batch_time_ms :.2f} ms ({ total_loaded / batch_time_ms * 1000 :.0f} rows/sec) [{ num_chunks } chunks]\n '
1650+ rows_per_sec = total_loaded / batch_time_ms * 1000
1651+ timing_msg = (
1652+ f'⏱️ Batch load complete: { total_loaded } rows in { batch_time_ms :.2f} ms '
1653+ f'({ rows_per_sec :.0f} rows/sec) [{ num_chunks } chunks]\n '
1654+ )
16531655 sys .stderr .write (timing_msg )
16541656 sys .stderr .flush ()
16551657
@@ -1661,7 +1663,10 @@ def _load_via_streaming(self, batch: pa.RecordBatch, table_name: str, **kwargs)
16611663
16621664 t_batch_end = time .perf_counter ()
16631665 batch_time_ms = (t_batch_end - t_batch_start ) * 1000
1664- timing_msg = f'⏱️ Batch load complete: { len (rows )} rows in { batch_time_ms :.2f} ms ({ len (rows ) / batch_time_ms * 1000 :.0f} rows/sec)\n '
1666+ rows_per_sec = len (rows ) / batch_time_ms * 1000
1667+ timing_msg = (
1668+ f'⏱️ Batch load complete: { len (rows )} rows in { batch_time_ms :.2f} ms ({ rows_per_sec :.0f} rows/sec)\n '
1669+ )
16651670 sys .stderr .write (timing_msg )
16661671 sys .stderr .flush ()
16671672
0 commit comments