パラメータ テーブル名を挿入します。最も最適で最良の方法は何でしょうか?
私はこのコードを持っていますが、それは機能しますが、1行で割り当てを使用できるかどうかを考えています. これは私のコードです。
sql = """INSERT INTO {} (exchange, buy, sell) VALUES (% s,% s,% s)""". format (table)
self.cursor.execute (sql, (exchange, buy, sell))
self.connection.commit ()
これを実行しようとしますが、うまくいきません。
sql = """INSERT INTO {} (exchange, buy, sell) VALUES ({}, {}, {})""". format (table, exchange, buy, sell)
最後の文で、return error not found exchanges.'mytable'
sql = """INSERT INTO %s (exchange, buy, sell) VALUES (% s,% s,% s)""% (table, exchange, buy, sell)