55import queue as qu
66import threading
77from contextlib import suppress
8- from io import StringIO
98from urllib .parse import quote_plus
109
1110from sqlalchemy import create_engine , text
2019 get_tg_schema ,
2120 get_tg_username ,
2221)
22+ from testgen .common .database import FilteredStringIO
2323from testgen .common .encrypt import DecryptText
2424from testgen .common .read_file import get_template_files
2525
@@ -582,15 +582,14 @@ def RetrieveSingleResultValue(strCredentialSet, strRunSQL):
582582def WriteListToDB (strCredentialSet , lstData , lstColumns , strDBTable ):
583583 LOG .info ("CurrentDB Operation: WriteListToDB. Creds: %s" , strCredentialSet )
584584 LOG .debug ("(Processing ingestion query: %s records)" , lstData )
585- # List should have same column names as destination table, though not all columns in table are required
586585
586+ # List should have same column names as destination table, though not all columns in table are required
587587 # Use COPY for DKTG database, otherwise executemany()
588-
589588 con = _InitDBConnection (strCredentialSet , "Y" )
590589 cur = con .cursor ()
591590 if strCredentialSet == "DKTG" :
592591 # Write List to CSV in memory
593- sio = StringIO ( )
592+ sio = FilteredStringIO ([ " \x00 " ] )
594593 writer = csv .writer (sio , quoting = csv .QUOTE_MINIMAL )
595594 writer .writerows (lstData )
596595 sio .seek (0 )
@@ -602,7 +601,6 @@ def WriteListToDB(strCredentialSet, lstData, lstColumns, strDBTable):
602601
603602 cur .copy_expert (strCopySQL , sio )
604603 con .commit ()
605-
606604 else :
607605 # Get list of column names and column names formatted as parms
608606 strColumnNames = ", " .join (lstColumns )
0 commit comments