sql update set ? = ? where ? = ? (python, sqlite3)
<p>Python, slite3</p>

<pre><code>c.execute("UPDATE accounts SET ? = ? WHERE num=?", (db['choise'], db['data'], db['num']))
</code></pre>

<p>so i don't know what is wrong with it</p>

<p>db is shelve database</p>

<p>The column (and table) names <em>cannot be parameterized</em>. Use string formatting for it and query parameterization for the rest of variables:</p>

<pre><code>c.execute("UPDATE accounts SET {column} = ? WHERE num = ?".format(column=db['choise']), (db['data'], db['num']))
</code></pre>

<p>That said, make sure you properly validate/sanitize/escape the <code>db['choise']</code> value or really trust the source of it (though don't trust anyone when it comes to database interactions).</p>

python sqlite3