Please take this survey to help us learn more about how you use third party tools. Your input is greatly appreciated!

COPY - Python ODBC issue

Hi, I have a problem with calling COPY function from Python application. The Python code connects to the Vertica DB with ODBC.

This is my query: copy temp_table from data/Vertica_common.txt REJECTMAX 10 DELIMITER '|' DIRECT

This is what I got from my python code:  ProgrammingError('42601', '[42601] ERROR 4856:  Syntax error at or near "data" at character 34\n (4856) (SQLExecDirectW)')

Could you give me an advice how to fix that?

Thanks,
Jakub

Comments

  • Hi Jakub,

    The file path is supposed to be an absolute path; also a string literal.  Could you try something like?:

    copy temp_table from '/data/Vertica_common.txt' REJECTMAX 10 DELIMITER '|' DIRECT

    COPY, by default, assumes that the file is stored on the remote Vertica cluster.  If it is instead local to the client machine, you could do:

    copy temp_table from local 'data/Vertica_common.txt' REJECTMAX 10 DELIMITER '|' DIRECT

    (Note that relative paths are ok with "LOCAL"; that's because they have something to be relative to, ie., the current working directory of the client application.)

    Note that COPY LOCAL ships the file data over the network to Vertica.  Which can be a very useful feature.  But it's a bit silly (therefore a bit slower than regular COPY, which just opens the file directly) if your client application is on the same machine as your Vertica server, so the file is already local and doesn't need to be shipped over the network.

    Adam
  • hey Adam, thanks for the whole explanation. Now it works fine.

    Cheers,
    Jakub

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file

Can't find what you're looking for? Search the Vertica Documentation, Knowledge Base, or Blog for more information.