\copy {% if data.query %}({{ data.query }}) {% else %}{{ conn|qtIdent(data.schema, data.table) }}{% if columns %}{{ columns }} {% endif %}{% endif %} {% if data.is_import %}FROM{% else %}TO{% endif %} {{ data.filename|qtLiteral(conn) }} WITH(FORMAT {{data.format}}{% if data.delimiter and data.format != 'binary' and data.delimiter == '[tab]' %}, DELIMITER E'\t'{% elif data.format != 'binary' and data.delimiter %}, DELIMITER {{ data.delimiter|qtLiteral(conn) }}{% endif %}{% if data.format == 'csv' and data.header %}, HEADER{% endif %}{% if data.freeze %}, FREEZE{% endif %}{% if data.encoding %}, ENCODING {{ data.encoding|qtLiteral(conn) }}{% endif %}{% if data.format == 'csv' and data.quote %}, QUOTE {{ data.quote|qtLiteral(conn) }}{% endif %}{% if data.format != 'binary' and data.null_string %}, NULL {{ data.null_string|qtLiteral(conn) }}{% endif %}{% if data.format != 'binary' and data.is_import and data.default_string %}, DEFAULT {{ data.default_string|qtLiteral(conn) }}{% endif %}{% if data.format == 'csv' and data.escape %}, ESCAPE {{ data.escape|qtLiteral(conn) }}{% endif %}{% if data.format == 'csv' and data.is_import and not_null_columns %}, FORCE_NOT_NULL {{ not_null_columns }}{% endif %}{% if data.format == 'csv' and data.is_import and null_columns %}, FORCE_NULL {{ null_columns }}{% endif %}{% if data.format == 'csv' and not data.is_import and force_quote_columns %}, FORCE_QUOTE {{ force_quote_columns }}{% endif %});
