Updated on 2023-10-23 GMT+08:00

Executing SQL Statements

  1. Construct an operation statement and use %s as a placeholder. During execution, psycopg2 will replace the placeholder with the parameter value. You can add the RETURNING clause to obtain the automatically generated column values.
  2. The cursor.execute method is used to perform operations on one row, and the cursor.executemany method is used to perform operations on multiple rows.