Skip to content

How to execute an SQL file? #2100

Open
Open
@gajus

Description

@gajus

This has been asked before (e.g. #1763), and the answer was to just use query(). However, this no longer seems to work:

severity: ERROR
code:     42601
file:     postgres.c
line:     1400
routine:  exec_parse_message
name:     Error
message:  cannot insert multiple commands into a prepared statement

This is at least the case with the native driver.

What is the correct way to split SQL file by query and execute it?

StackOverflow suggests adhoc implementations such as this: https://stackoverflow.com/a/22659240/368691 However, they are utterly unsafe (any SQL that includes ; will break).

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions