Psycopg2 - not all arguments converted during string formatting

后端 未结 1 1633
暗喜
暗喜 2021-01-12 19:57

I\'m trying to insert the value of the variable test_text into a Postgres 9.6 database, each time the database_insert function is triggered.

I\'m using Python 3.6 an

相关标签:
1条回答
  • 2021-01-12 20:39

    There's a subtle issue here.

    You need a comma to make a tuple not just the parens/brackets.

    So simply change to:

    cur.execute("INSERT INTO test VALUES(%s);", (test_text,))
    

    And you should be good!

    0 讨论(0)
提交回复
热议问题