Skip to content

Commit d2a9866

Browse files
authored
Merge pull request #33 from DataKitchen/release/3.7.3
Release/3.7.3
2 parents cdeb8d2 + ed8f826 commit d2a9866

3 files changed

Lines changed: 16 additions & 5 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from collections.abc import Iterable
2+
from io import StringIO
3+
4+
5+
class FilteredStringIO(StringIO):
6+
def __init__(self, filtered: Iterable[str], *args, **kwargs):
7+
self._replacements = str.maketrans(dict.fromkeys(filtered or [], ""))
8+
super().__init__(*args, **kwargs)
9+
10+
def write(self, to_write: str):
11+
return super().write(to_write.translate(self._replacements))

testgen/common/database/database_service.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import queue as qu
66
import threading
77
from contextlib import suppress
8-
from io import StringIO
98
from urllib.parse import quote_plus
109

1110
from sqlalchemy import create_engine, text
@@ -20,6 +19,7 @@
2019
get_tg_schema,
2120
get_tg_username,
2221
)
22+
from testgen.common.database import FilteredStringIO
2323
from testgen.common.encrypt import DecryptText
2424
from testgen.common.read_file import get_template_files
2525

@@ -582,15 +582,14 @@ def RetrieveSingleResultValue(strCredentialSet, strRunSQL):
582582
def 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)

testgen/ui/views/connections/page.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ def show_connection_form(self, selected_connection: dict, _mode: str, project_co
124124
"private_key": None,
125125
})
126126

127+
data.setdefault("http_path", "")
128+
127129
try:
128130
FlavorForm(**data)
129131
except ValidationError as error:

0 commit comments

Comments
 (0)