select name where id = "in the python list"?
<p>Let's say i have a python list of customer id like this:</p>

<pre><code>id = ('12','14','15','11',.......)
</code></pre>

<p>the array has 1000 values in it, and i need to insert the customer name to a table based on the ids from the list above.</p>

<p>my code is like:</p>

<pre><code>ids = ",".join(id)
sql = "insert into cust_table(name)values(names)where cust_id IN('ids')"
cursor.execute(sql)
</code></pre>

<p>after running the code, i get nothing inserted to the table. What mistake do i have?</p>

<p>Please help :(</p>

<p>You need to format the string.</p>

<pre><code>ids = ",".join(id)
sql = "insert into cust_table(name)values(names)where cust_id IN('{ids}')"
cursor.execute(sql.format(ids= ids))
</code></pre>

python mysql