README.md in postgres-copy-1.6.1 vs README.md in postgres-copy-1.7.0
- old
+ new
@@ -1,6 +1,6 @@
-# postgres-copy
+# postgres-copy
![Ruby](https://github.com/diogob/postgres-copy/workflows/Ruby/badge.svg)
This Gem will enable your AR models to use the PostgreSQL COPY command to import/export data in CSV format.
If you need to tranfer data between a PostgreSQL database and CSV files, the PostgreSQL native CSV parser
@@ -205,9 +205,22 @@
```ruby
User.copy_from "/tmp/users_with_byte_order_mark.csv", :encoding => 'bom|utf-8'
```
+### Using PostgresCopy::WithTempTable.generate
+
+Based on [nfedyashev](https://github.com/nfedyashev)'s [comment](https://github.com/diogob/postgres-copy/issues/51):
+
+```ruby
+ PostgresCopy::WithTempTable.generate do |t|
+ columns.each do |column_name|
+ t.string column_name.to_sym
+ end
+ end
+```
+
+This auto-generates an id column, but the temp table creation is configurable.
### Using the CSV Responder
If you want to make the result of a COPY command available to download this gem provides a CSV responder that, in conjunction with [inherited_resources](https://github.com/josevalim/inherited_resources), is a very powerfull tool. BTW, do not try to use the responder without inherited_resources.
The advantage of using this CSV responder over generating the CSV file, is that it will iterate over the resulting lines and send them to the client as they became available, so you will not have any problem with memory consumption or timeouts executing the action.