0

I have the following code:

import psycopg2  
    import psycopg2
    conn = psycopg2.connect(database = 'xxxx', user = 'xxxx',password = 'xxxx',host = 'localhost', port = '5432')
    cur = conn.cursor()
    carl = 'Sioux Quartzite'
    sql = '''INSERT INTO GEOLOGY (FORM_NAME) VALUES (%s);''',(carl)
    cur.execute(sql) 
    conn.commit() 
    conn.close()

The error back from Python (which is the one in QGIS) gives me the following error code:

It is readily apparent I am a novice. I have tried every combination of parentheses and tried to use the answers on this forum that came close. All I want to do is insert the value of 'carl' which is the string 'Sioux Quartzite' into PostGreSQL. All my choices have presented similar errors and it is only the sql statement confounding me.

Thanks

Traceback (most recent call last):
  File "C:\PROGRA~1\QGIS32~1.3\apps\Python39\lib\code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
  File "<string>", line 69, in <module>
TypeError: argument 1 must be a string or unicode object: got tuple instead

0 Answers0