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

Commit d7acd93

Browse files
author
dames
committed
Improved Null handling. Nullable dates/ints now work.
1 parent 30612d3 commit d7acd93

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

configuraton/provider.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,23 @@
8282
"type": "sqlalchemy.DateTime",
8383
"nullable": true
8484
}
85+
},
86+
{
87+
"source_name": "LongString",
88+
"destination": {
89+
"name": "long_string",
90+
"type": "citext.CIText",
91+
"nullable": true
92+
}
93+
},
94+
{
95+
"source_name": "UnicodeString",
96+
"destination": {
97+
"name": "unicode_string",
98+
"type": "citext.CIText",
99+
"nullable": true
100+
}
85101
}
102+
86103
]
87104
}

relational_data_loader_project/BatchDataLoader.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ def write_data_frame_to_table(self, data_frame, table_configuration, target_engi
6161
destination_table = "{0}.{1}".format(table_configuration['schema'], table_configuration['name'])
6262
self.logger.info("Starting write to table {0}".format(destination_table))
6363
data = StringIO()
64-
data_frame.to_csv(data, header=False, index=False)
64+
data_frame.to_csv(data, header=False, index=False, na_rep='')
6565
data.seek(0)
6666
raw = target_engine.raw_connection()
6767
curs = raw.cursor()
6868

6969
column_array = list(map(lambda cfg: cfg['destination']['name'], self.columns))
7070

71-
curs.copy_from(data, destination_table, sep=',', columns=column_array)
71+
curs.copy_from(data, destination_table, sep=',', columns=column_array, null='')
7272
self.logger.info("Completed write to table {0}".format(destination_table))
7373

7474
curs.connection.commit()

0 commit comments

Comments
 (0)