In PostgreSQL I have backed up records of Table users to users.sql.
After some changes I made to data in other tables in the Database, PostgreSQL is not allowing me to restore the data from users.sql.
The only workaround available to me at this stage is to convert users.sql to .csv file and then copy & paste the data into Table users.
Is there a way to convert PostgreSQL backup file users.sql to users.csv?
users.sqltousers.csv. Hence, looking for a solution to understand the file format ofPostreSQL.sqlfile or a tool to convert it to.csvfile format or.txtfile format. So is there a way?COPY users_no_fks to /path/to/users.csv CSV HEADER;.users.sqldump file is in Binary format. If it had been text, then there is no issue at all.pg_restore --section=data -f /path/to/new_users.sql /path/to/existing/users.sql, which will create a new_users.sql with only a COPY statement with the table data. Edit the table name there, create the corresponding FK-less table in your DB, restore & re-export, and you have your CSV. (pg_restore cannot convert to CSV directly; the best you can do is --section=data to get a plain-text dump of just the table data before proceeding with the load & re-export steps.)