0

I'm trying to use the copy command to copy the content of a file into a database. One of the lines have this:

CCc1ccc(cc1)C(=O)/N=c\1/n(ccs1)C

and when i insert this normally into database there is no errors.

But when i'm trying to use the following command, this line is not insert correctly.

cat smile_test.txt | psql -c "copy testzincsmile(smile) from stdout" teste

This i what i get (it is wrong):

CCc1ccc(cc1)C(=O)/N=c/n(ccs1)C

What's wrong here?

Thank you :)

2 Answers 2

1

copy expects a specific input format and cannot just be used to read random text from a file into a field.

See the manual.

The specific issue you're hitting is probably a backslash being interpreted as an escape by the default copy in/out format.

Sign up to request clarification or add additional context in comments.

Comments

0

I figure out how to do this:

This is my answer:

cat smile_test.txt | sed '1d; s/\\/\\\\/g' | psql -c "copy testzincsmile(smile) from stdout" teste

1 Comment

Well, that's a workaround for this specific issue but not other possible problems, and it's still not really how copy should work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.