AlisdairO / pgexercises

PostgreSQL Exercises web site code
Other
400 stars 62 forks source link

Avoid usage of COPY in exported schema #20

Closed olliebennett closed 7 years ago

olliebennett commented 8 years ago

Some tools do not support the COPY command;

COPY tablename (columnnames) FROM stdin

I propose the clubdata.sql dump be converted to use simple INSERT statements.

For example,

COPY facilities (facid, name, membercost, guestcost, initialoutlay, monthlymaintenance) FROM stdin;
0   Tennis Court 1  5   25  10000   200
1   Tennis Court 2  5   25  8000    200
...
\.

would become

INSERT INTO facilities (facid, name, membercost, guestcost, initialoutlay, monthlymaintenance) VALUES
    (0, 'Tennis Court 1', 5, 25, 10000, 200),
    (1, 'Tennis Court 2', 5, 25, 8000, 200),
...
;

I appreciate the (minor) added verbosity is unpleasant, but perhaps compatibility should be prioritised.

My use-case was building the schema for sharing on SQL Fiddle which uses PostgreSQL 9.3.

When attempting to import the SQL into SQLFiddle.com, the following error was displayed:

The JDBC driver currently does not support COPY operations.

AlisdairO commented 8 years ago

Seems reasonable! I will put this on the backlog. Afraid it's not likely to happen in the near future unless someone does it for me, as I'm currently mid-emigration! Thank you for the issue :-)

AlisdairO commented 7 years ago

Hey, finally got round to this - commit id fe9857dd773da484ffabd00bbf6c96b14b439945