Revision 5572
Added by Aaron Marcuse-Kubitza about 12 years ago
lib/sql_io.py | ||
---|---|---|
237 | 237 |
if use_copy_from: |
238 | 238 |
log('Using COPY FROM') |
239 | 239 |
|
240 |
# Wrap in standardizing stream |
|
241 |
cols_ct = len(stream_info.header) |
|
242 |
stream = csvs.InputRewriter(csvs.ColCtFilter(csvs.make_reader(stream, |
|
243 |
dialect), cols_ct)) |
|
244 |
dialect = stream.dialect # use default dialect |
|
245 |
|
|
240 | 246 |
# Create COPY FROM statement |
241 | 247 |
copy_from = ('COPY '+table.to_str(db)+' FROM STDIN DELIMITER ' |
242 | 248 |
+db.esc_value(dialect.delimiter)+' NULL '+db.esc_value('')) |
Also available in: Unified diff
sql_io.py: append_csv(): COPY FROM: Wrap provided stream in standardizing stream to fix ragged rows (with unequal # columns) and nonstandard CSV dialects (such as TSV with \-escaped newlines)