Clickhouse: Error: INTO OUTFILE is not allowed

Created on 8 May 2018  Â·  3Comments  Â·  Source: ClickHouse/ClickHouse

Hello dier support.
When I am doing some query, I am receiving Error: INTO OUTFILE is not allowed

echo "SELECT * from test.\stats` where date = '2018-05-04' INTO OUTFILE '/var/lib/clickhouse/user_files/1525769878920.csv'" | curl 'http://admin:123456@localhost:8123/' -d @-`

How I can set parameter allow_into_outfile in config file?

question

All 3 comments

As stated in the docs, the output file is created on the client side. It is pretty hard to do via the HTTP interface :) So INTO OUTFILE is disabled in this case. You can use clickhouse-client for that.

I made it via the shell

ssh [email protected] /bin/bash << EOF
    clickhouse-client --user=admin --password=111111 --query="SELECT * FROM test.\"stats\" AS t WHERE date = '2018-04-07'  INTO OUTFILE '/user/reports/1525777158845.csv' FORMAT CSVWithNames"
EOF

My nodejs solution

const { exec } = require('child_process');

function clientExec(sql) {
    return new Promise((resolve, reject) => {

        const command = config.useSSH ? sshExec(sql) : callClient(sql);

        exec(command, (error, stdout, stderr) => {
            if (error) return reject(error);
            if (stderr) return reject(stderr);
            resolve(stdout);
        });

    });
}
function callClient(sql) {
    return 'clickhouse-client --user=user --password=111111 --query=" '+ ${sql} +' "';
}

function sshExec(sql) {
    return 'ssh [email protected] /bin/bash << EOF\n' +
        '    '+callClient(sql)+'\n' +
        'EOF\n';
}

As stated in the docs, the output file is created on the client side. It is pretty hard to do via the HTTP interface :) So INTO OUTFILE is disabled in this case. You can use clickhouse-client for that.

Hey @ztlpn Can you please point to me where I can find the reasons why it is disabled over the HTTP interface and any issue which is tracking this feature?

Was this page helpful?
0 / 5 - 0 ratings