unable to insert string or read-only buffer, not long
<p>I tried to venture off while following a python-flask tutorial and am having trouble figuring out an error. I tried browsing stack for 6 hours off and on and nothing out there related could help me out, possibly because I am a beginner...</p>

<p>I gathered data from a form (all the data is passing through fine, I tested by printing to the console) and want to insert it into a mysql table.</p>

<p>Here is the query code:</p>

<pre><code>c.execute("INSERT INTO posts (post_count, seller, title, id, bus, condition, transType, post_description, trade, price) VALUES (%i, %s, %s, %s, %s, %s, %s, %s, %s, %i)", (thwart(postCount), thwart(seller), thwart(title), thwart(id), thwart(bus), thwart(condition), thwart(transType), thwart(description), thwart(tradeFor), thwart(price)))
</code></pre>

<p>The table description in MySql is:</p>

<pre><code>+------------------+-------------+------+-----+---------+----------------+
| Field            | Type        | Null | Key | Default | Extra          |
+------------------+-------------+------+-----+---------+----------------+
| post_id          | int(11)     | NO   | PRI | NULL    | auto_increment |
| post_count       | int(11)     | YES  |     | NULL    |                |
| seller           | varchar(60) | YES  |     | NULL    |                |
| title            | text        | YES  |     | NULL    |                |
| id               | varchar(25) | YES  |     | NULL    |                |
| bus              | varchar(35) | YES  |     | NULL    |                |
| condition        | varchar(20) | YES  |     | NULL    |                |
| transType        | varchar(25) | YES  |     | NULL    |                |
| post_description | text        | YES  |     | NULL    |                |
| trade            | text        | YES  |     | NULL    |                |
| price            | int(11)     | YES  |     | NULL    |                |
+------------------+-------------+------+-----+---------+----------------+
</code></pre>

<p>The error I keep getting is: <code>must be string or read-only buffer, not long</code></p>

<p>I don't see where the long is coming from...Not sure what else you may need to help me out so ask if there's more info I can add.</p>

<p>much appreciated!</p>

<p>Check all the variables <code>type</code> which are being inserted. </p>

<p>I would guess one of them is suppose to be text or varchar, but is a <code>long</code>. </p>

<p>Try converting the <code>long</code> to a <code>str</code> basically one of the numbers being inserted isnt text but might look like 37582L</p>

<pre><code>print(type(post_count))
print(type(seller))
print(type(post_description))

if type(some_long) is long:
    do_insert(str(some_long))
</code></pre>

python mysql