Home > Net >  syntax to pass multiple variables into query
syntax to pass multiple variables into query

Time:10-11

When I try adding 2 columns, my query works fine

('INSERT INTO TABLE (JSON_S, LOAD_DATE) SELECT PARSE_JSON(?), CURRENT_TIMESTAMP', [[content]] )

However, when I try to add another variable (string):

('INSERT INTO TABLE (JSON_S, LOAD_ID, LOAD_DATE) SELECT PARSE_JSON(?), (?), CURRENT_TIMESTAMP', [[content]], load_id)

I get an error that:

Bind variable ? not set.

What's the correct syntax?

CodePudding user response:

Arguments should be provided as tuple:

con.cursor().execute("INSERT INTO TABLE (JSON_S, LOAD_ID, LOAD_DATE) SELECT PARSE_JSON(?), ?, CURRENT_TIMESTAMP()"
    ,(content, load_id))
  • Related