私は初心者です。このコードを使用してSQLコマンドを実行します。psycopgを使用したprepared statements
cur.execute("INSERT INTO test (num, data) VALUES (%s, %s)", (100, "abcdef"))
私はこの準備されたステートメントかクライエント側が引用しているのだろうか?
私は初心者です。このコードを使用してSQLコマンドを実行します。psycopgを使用したprepared statements
cur.execute("INSERT INTO test (num, data) VALUES (%s, %s)", (100, "abcdef"))
私はこの準備されたステートメントかクライエント側が引用しているのだろうか?
いいえ、少なくともpsycopg2ではありません。ドキュメント内の「準備」とは、準備済みの文とはまったく異なる「準備中のトランザクション」を指します。
ただし、プリペアドステートメントをエミュレートするには、メソッドをオーバーライドするか、余分なステートメントを実行します。参照:An example of psycopg2 cursor supporting prepared statements
をご覧ください。relevant blog entry for psycopg.
詳細情報:
http://www.postgresql.org/docs/9.2/static/sql-prepare.html
http://www.postgresql.org/docs/current/static/sql-prepare-transaction.html
こちらをご覧ください: http://stackoverflow.com/questions/6775497/psycopg-get-書式設定されたSQLの代わりに – socketpair