D
D
demortall2022-02-17 23:14:37
PostgreSQL
demortall, 2022-02-17 23:14:37

Psycopg2.errors.SyntaxError: syntax error at or near "M5BSJAV6AY"?

I'm trying to write a random string to a JSON cell

hash = ''.join(random.choices(string.ascii_uppercase + string.digits, k = 10))    
cursor.execute("""UPDATE settings SET register = '{"value":"enabled", "link": %s}'  WHERE worker=%s""", [hash, id])

But returns
cursor.execute("""UPDATE settings SET register = '{"value":"enabled", "link": %s}' WHERE worker=%s""", [hash, id])
psycopg2.errors .SyntaxError: syntax error at or near "M5BSJAV6AY"
LINE 1: ...ings SET register = '{"value":"enabled", "link": 'M5BSJAV6AY...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2022-02-17
@demortall

json collect with python, json.dumps and paste the result already

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question