I am writing a simple Golang based Redshift DataLoader. I have to use Redshift Copy From S3 command as Prepared statement so that I can pass credentials as part of an argument.
I see lib/pq is not parsing the SQL template correctly. Any thoughts would be appreciated
COPY_FROM_S3 = `
COPY {{.stageTable}}
FROM $1
WITH CREDENTIALS AS $2
DELIMITER $3
IGNOREBLANKLINES ACCEPTINVCHARS BLANKSASNULL
EMPTYASNULL ACCEPTANYDATE ESCAPE MAXERROR 50
STATUPDATE ON
`
stmt , _ := redshiftDB.Prepare(COPY_FROM_S3)
stmt.Exec(s3File, awsCreds, delimter)
Getting Syntax error
panic: pq: syntax error at or near "$1"
goroutine 1 [running]:
lib/pq is indeed parsing it correctly, the problem is you're creating an invalid query template, first: {{.stageTable}}
is for formal templates, second: dollars ($1) notation doesn't work for table names in FROM statement and not sure if the other **$**s will work