B
B
beduin012016-05-28 12:02:00
Python
beduin01, 2016-05-28 12:02:00

Where is the error in insert query in Postgres?

Here is my code:

output_file_name_read = open(output_file_name,'rb').read() # там мы писали, тут читаем
        # SQL_update_request = """UPDATE "REQUESTS" SET shape = {0} WHERE request_id = 6""".format(psycopg2.Binary(output_file_name_read))
        currDst.execute("""UPDATE "REQUESTS" SET shape = %s WHERE request_id = 7""", psycopg2.Binary(output_file_name_read))
        postconn.commit()

On startup I get an error:
Traceback (most recent call last):
  File "C:\work\App.py", line 67, in <module>
    main()
  File "C:\work\App.py", line 64, in main
    SyncRequest(postconn, fireconn, 'POSTID', 'FIREID')
  File "C:\work\App.py", line 49, in SyncRequest
    currDst.execute("""UPDATE "REQUESTS" SET shape = %s WHERE request_id = 7""", psycopg2.Binary(output_file_name_read))
  File "C:\Python27\ArcGIS10.1\lib\site-packages\fdb\fbcore.py", line 3322, in execute
    PreparedStatement(operation, self, True))
  File "C:\Python27\ArcGIS10.1\lib\site-packages\fdb\fbcore.py", line 1934, in __init__
    "Error while preparing SQL statement:")
fdb.fbcore.DatabaseError: ('Error while preparing SQL statement:\n- SQLCODE: -104\n- Dynamic SQL Error\n- SQL error code = -104\n- Token unknown - line 1, column 31\n- %', -104, 335544569)

What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
lubezniy, 2016-05-28
@lubezniy

And where is the value %s substituted in the query?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question