title: ProgrammingError - sqlalchemy - on_conflict_do_update
body: <p>Following this <a href="https://stackoverflow.com/q/49727254/5665430">question</a>:</p>
  
  <p>As Ilja Everilä mentioned in his <a href="https://stackoverflow.com/a/49732953/5665430">answer</a>, I created a table object:</p>
  
  <pre><code>from sqlalchemy import *
  metadata = MetaData()
  idTagTable = Table('id_tag', metadata,
                   Column('id', String(255), primary_key = True),     
                   Column('category', String(20), nullable = False),
                   Column('createddate', Date, nullable = False),
                   Column('updatedon', Date, nullable = False)
                   )
  </code></pre>
  
  <p>After creating a table object, I changed insert and update statements:</p>
  
  <pre><code>insert_statement = sqlalchemy.dialects.postgresql.insert(idTagTable)
  upsert_statement = insert_statement.on_conflict_do_update(
          constraint=PrimaryKeyConstraint('id'),
          set_={"updatedon": insert_statement.excluded.updateon,
                "category":insert_statement.excluded.category}
  )
  insert_values = df.to_dict(orient='records')
  conn.execute(upsert_statement, insert_values)
  </code></pre>
  
  <p>Now I am getting Programming Error:</p>
  
  <pre><code>Traceback (most recent call last):
  
  File "&lt;ipython-input-66-0fc6a1bf9c6b&gt;", line 7, in &lt;module&gt;
  conn.execute(upsert_statement, insert_values)
  
  File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 945, in execute
  return meth(self, multiparams, params)
  
  File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/sqlalchemy/sql/elements.py", line 263, in _execute_on_connection
  return connection._execute_clauseelement(self, multiparams, params)
  
  File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1053, in _execute_clauseelement
  compiled_sql, distilled_params
  
  File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1189, in _execute_context
  context)
  
  File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1402, in _handle_dbapi_exception
  exc_info
  
  File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause
  reraise(type(exception), exception, tb=exc_tb, cause=cause)
  
  File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1159, in _execute_context
  context)
  
  File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 467, in do_executemany
  cursor.executemany(statement, parameters)
  
  ProgrammingError: (psycopg2.ProgrammingError) syntax error at or near 
  ")"
  LINE 1: ...category) VALUES ('sports') ON CONFLICT () DO UPDAT...
                                                      ^
  </code></pre>
  
  <p>Not Able to understand why I am getting this error.</p>