title: Calling upon data in just 1 cell from sqlite in python
body: <p>My question is essentially twofold. Firstly, I have a database using SQlite, which I'm running with Python. </p>
  
  <p>My database is:</p>
  
  <pre><code>CREATE TABLE cards (id integer primary key autoincrement not null, ref text unique
  check(ref!=''), name text, description text, quantity integer default 0, cat1 text,
  cat2 text);
  
  INSERT INTO "cards" VALUES(1,'lx247','green door',NULL,20,'abstract','');
  INSERT INTO "cards" VALUES(2,'lxx247','green door',NULL,20,'abstract','');
  INSERT INTO "cards" VALUES(3,'lxx2f47','green door',NULL,20,'abstract','');
  </code></pre>
  
  <p>And I'm running the following python code:</p>
  
  <pre><code>import sqlite3 as lite
  import sys
  con = lite.connect('cards.db')
  idn = raw_input("Enter your ID number")
  with con:
      cur=con.cursor()
      cur.execute("SELECT quantity FROM cards WHERE ref=?", idn)  
      print "Quantity" + str(cur.fetchone())
  </code></pre>
  
  <p>Firstly, when I execute this script, and enter 'lx247' into the prompt, I get the following error message:</p>
  
  <pre><code>Enter your ID numberlx247
  Traceback (most recent call last):
    File "test1.py", line 7, in &lt;module&gt;
      cur.execute("SELECT quantity FROM cards WHERE ref=?", idn)  
  sqlite3.ProgrammingError: Incorrect number of bindings supplied. 
  The current statement uses 1, and there are 5 supplied.
  </code></pre>
  
  <p>I've identified that the 5 it refers to are the number of characters in what I enter into the idn input (lx247). If I change the line:</p>
  
  <pre><code>cur.execute("SELECT quantity FROM cards WHERE ref=?", idn)  
  </code></pre>
  
  <p>to </p>
  
  <pre><code>cur.execute("SELECT quantity FROM cards WHERE id=?", idn)   
  </code></pre>
  
  <p>and enter '2' at the prompt, it returns:</p>
  
  <pre><code>Enter your ID number2
  Quantity(20,)
  </code></pre>
  
  <p>So this has told me there is something wrong with the way it is handling the idn parameter to look up the ref column. So my first question is <strong>how do I get it to look up the value I enter in idn in column ref</strong>?</p>
  
  <p>The second question is how do I then get it to output the value as a number, rather than in the form (20,), because I then want to later direct python to add or subtract another number, x, to it and update the entry in the database to 20+x, so I'm looking to create a variable in python that is the value of the quantity column for a certain ref entry.</p>