pg_sample icon indicating copy to clipboard operation
pg_sample copied to clipboard

Export data with inserts statements

Open ash67 opened this issue 3 years ago • 4 comments

Is it possible to export data with insert statements over COPY?

ash67 avatar May 20 '22 04:05 ash67

Not as written. Why do you prefer inserts?

mla avatar May 22 '22 16:05 mla

@mla thanks for getting back to me! I m using pgmem for unit tests. It does not allow COPY to populate the db.

ash67 avatar May 22 '22 22:05 ash67

k, we'd have to look. The COPY is convenient since we kind of fake it out.. we tell it we're going to create the real table name, but then we dump the data from the sample tables. Not sure how we can do that with inserts easily.

But one hack might be to use pg_sample to generate the sample db. Restore it. And then use pg_dump to dump it as insert statements.

mla avatar May 23 '22 06:05 mla

@mla thanks! The hack has worked for me. It does the job.

ash67 avatar May 24 '22 03:05 ash67