Import From File in Lua Script

Padawan

Hi,

I have been trying to load csv files from lua script. But I am getting the error below.

sibi_e_0-1598538694209.png

 When I run the import statement alone, its working fine. Here is my code.

CREATE OR REPLACE LUA SCRIPT TEST_LOAD () RETURNS TABLE AS
query([[
	IMPORT INTO TEST_TABLE
	FROM LOCAL CSV FILE 'F:\test_file.csv'
	ENCODING = 'UTF-8'
	ROW SEPARATOR = 'CRLF' 
	COLUMN SEPARATOR = ',' 
	SKIP = 1
]]);

EXECUTE SCRIPT TEST_LOAD ();

 Kindly share your ideas

2 REPLIES 2

Contributor

Hi!
What you can do is to save the SQL into a file and run that from the Exasol_CLI, that's what I'm using for creation of exports.

Please see: https://docs.exasol.com/connect_exasol/sql_clients/exaplus_cli/exaplus_cli.htm

HTH

Michael

Xpert

Hi,

as the error message suggest this can only be done from within a jdbc based application because a client part is used to do the actual IO with the local file and LUA can't access this component (LUA is running in the engine).

What you could do is put that file on an FTP(s) server. In that case you would be able to import the file in LUA.