Skip to content
This repository was archived by the owner on Mar 13, 2020. It is now read-only.

Commit c2e6dad

Browse files
author
Sean Budd
committed
[OSC-1241] improve logging for data frame to csv to psql process
1 parent 9b8b78b commit c2e6dad

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,29 @@ Use the following vscode settings by either:
8181

8282
### Testing
8383

84+
### Postgres debugging
85+
86+
Ensure the database you are using is in utf8 mode. You cannot change encoding once the database is created.
87+
88+
```sql
89+
90+
CREATE DATABASE "my_database"
91+
WITH OWNER "postgres"
92+
ENCODING 'UTF8'
93+
TEMPLATE template0;
94+
95+
```
96+
97+
Also ensure that the database has the CITEXT extension by logging into the DB and adding it
98+
99+
```sql
100+
101+
>>>psql my_database
102+
103+
CREATE EXTENSION CITEXT;
104+
105+
```
106+
84107
#### Integration
85108

86109
The test batch files assume there is a user by the name of `postgres` on the system.

modules/BatchDataLoader.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ def write_data_frame_to_table(self, data_frame):
5858
raw = self.target_db.raw_connection()
5959
curs = raw.cursor()
6060

61+
# log CSV on debug
62+
if self.logger.getEffectiveLevel() == logging.DEBUG:
63+
with open(f'{qualified_target_table}.csv', 'w', encoding='utf-8') as f:
64+
f.write(data.getvalue())
65+
6166
column_array = list(
6267
map(lambda source_colum_name: self.get_destination_column_name(source_colum_name), data_frame.columns))
6368
column_list = ','.join(map(str, column_array))

0 commit comments

Comments
 (0)