Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My Googlefu is failing me. Are there any code snippets, either in Python or FORTRAN, that shows how to create binary files to be used by the COPY command in PostgreSQL?

share|improve this question
you mean how to create binary files which is used by copy commond? pg_restore with parameter -Fc can produce binary file. – francs Oct 14 '11 at 8:44
Yes, but I want to generate the files from another application. I have a numerical model in Fortran that generate Gigabytes of data that I want to import to Postegresql as fast as possible. – brorfred Oct 17 '11 at 18:21

Your best bet really is to create CSV files and then import them with COPY. If you want to, you can then wrap them simply in a COPY ... WITH CSV FROM STDIN statement.

The existing docs on the COPY command should be sufficient. See

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.