Note that there are some explanatory texts on larger screens.

plurals
  1. POPython TypeError: cannot concatenate 'str' and 'long' objects
    primarykey
    data
    text
    <p>I have few User provided information like <code>username</code>, <code>password</code>, <code>email</code>, etc. that user provides in a config file.</p> <p>I have the parsed data from the config file using configParser module.</p> <p>I want to enter these information to MySQL database.</p> <p>The Data is like:</p> <pre><code>Usename="ABC" password="ABC@1" email="abc123@xyz.com" </code></pre> <p>My insert statement is like: </p> <pre><code>"INSERT INTO userinfo (group_ID, rank_ID, login, password, first_name, last_name, email) VALUES ('" + groupid + "', '" + rankID + "', '" + userid + "', '" + password + "', '" + fname + "', '" + lname + "', '" + email + "')" </code></pre> <p>But it is not executing, as I am getting an error:</p> <pre><code>TypeError: cannot concatenate 'str' and 'long' objects </code></pre> <p>I have tried doing: <code>str(password)</code>, <code>str(email)</code> for the variables with mixed types, but no luck.</p> <p>Here, <code>group_ID</code> and <code>rank_ID</code> are integers.</p> <p>I have tried the following as suggested by one of the experts:</p> <pre><code>sql = "INSERT INTO userinfo (group_ID, rank_ID, login, password, first_name, last_name, email) " "VALUES (%s, %s, %s, %s, %s, %s, %s)", (groupid, rankID, userid, password, fname, lname, email) try: c.execute(sql4) conn.commit() except StandardError, e: print e conn.rollback() </code></pre> <p>But the error I get is: <code>query() argument 1 must be string or read-only buffer, not tuple</code></p> <p>What could be the possible solution?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload