Hi,
I'm trying to import a CSV file into a PostgreSQL DB.
Customer requires all data from appian must rely on that DB which is connected as datasource.
I'm using the plug in Excel tool and the Smart Service Import CSV to Database.
I got the following error from stdOut log:
ERROR ImportCsvToDatabase8 Error executing SQL org.postgresql.util.PSQLException: ERROR: syntax error at or near "," Position: 17
From database, i turned statements log on and i found out the following statement:
2024-03-29 17:32:08 UTC:10.245.48.249(51148):appian@postgres:[3319]:ERROR: syntax error at or near "," at character 17 2024-03-29 17:32:08 UTC:10.245.48.249(51148):appian@postgres:[3319]:STATEMENT: select `field1`, `field2` from `table` where 1=0 2024-03-29 17:32:08 UTC:10.245.48.249(51148):appian@postgres:[3319]:LOG: execute S_1: ROLLBACK
I'm running the same statement on my client in Postgres and i got the same error of course.
What I found out is that backtick is causing problems as it as a different use on o Postgres than MariaDb.
Do you know any workaround to bypass this problem?
Something to skip/bypass the backtick and use something different?
Thanks a lot
Alessandro
Discussion posts and replies are publicly visible
Do you need to do this frequently? If not, did you consider to just import that file directly using a DB tool?
yes, very frequently. It's a core process.
CSV files can be tricky, because there is not clearly defined format.
Are you sure that the DB error message relates to the import? It's a select statement.
Do you have any influence on how that file is created?
Is there any option to send that data to Appian avoiding that CSV file?
Can you post a row of that CSV file?
Did you try the various separator options in the smart service?
yeah, I Know.
Although the same file, with the same configuration in the smart service except for the data source, with the same tables configurations (everything lowercase), works fine with Appian MariaDb.
Separator is ; but as it works fine on MariaDb i don't think it's the cause of the issue.
Unfortunately no, I have no governance on those files and they cannot be avoided as part of the process.
I can't post those data, but the format is clearly string;string;... Even other reader ov CSV files like the one in DBeaver can read fine the file and query it as it was a table.
Reading on internet, postgres does not use backtiks to force column names to keep their case type, instead ". Backticks is for MariaDB and mySql.
I'm afraid it's a bug of the plugin
Why dont't you use Read Excel Paged function, instead of import csv to database, and then call an stored procedure to insert the data you just read.
IN that way , you'll avoid the bug od the smart service.
Unfortunately, it works only with excel spreadsheet as it needs to read a valis Office Open XML. My files are CSV (basically text with a separator)
I just try it.
IN that case, you could try converting your csv to json, or xml with this plugin..
community.appian.com/.../csv-conversion