I have a two sqlite tables of which both contain different items and their quantities. What I want to do is loop through the first table, select the quantity from the first table and subtract it from the quantity from the second table where the item names match.

(Table1)

```

items  | quantity
----------
sugar  | 50
Pen    | 10
apple  | 50
berry  | 1

```

Second Table(populated by user input)(Table 2)

```

items  |quantity
----------
sugar  |500
Pen    |5
apple   |8
berry  |1

```

So as I said, I want to loop through table 1 and get the quantity of sugar from the Table 1. Then loop through Table 2 and get the quantity of sugar in table 2 too, then finally subtract the values and return the value after the subtraction has been carried out. And then the same thing is done for the other items in the table1.(loop)

E.g. Using sugar,
(Quantity of Sugar from table 2 – Quantity of Sugar from table 1) 
(500 – 50) = 450
Then it returns the value 450 so I can use it in other functions 

Code Example.

```
import sqlite3

db = sqlite3.connect('example.db')
#db.execute('create table Table1 (items text, quantity integer)')
#db.execute('create table Table2 (items text, quantity integer)')
a = 'Sugar'
b = 50
c = 500
db.execute('insert into Table1 (items, quantity) values(?,?)',(a, b))
db.execute('insert into Table1 (items, quantity) values(?,?)',(a, c))
db.commit()
db.close()

def one():
    cursor = db.execute('select items from Table1')
    for i in cursor.fetchall():
        return i

def two():
    cursor1 = db.execute('select quantity from Table1 where items = ?',(one()))
    for i in cursor1.fetchall():
        return i

def three():
    cursor1 = db.execute('select quantity from Table2 where items = ?',(one()))
    for i in cursor1.fetchall():
        return i

def subtraction():
    t = three() - two()
    return t

```

The error shown when i run the above code
File "C:/Users/MegaMind/Documents/Programming/Pycham Projects/New folder/package.py", line 22, in subtraction
 t = three() - two()
TypeError: unsupported operand type(s) for -: 'tuple' and 'tuple'

If there is a cleaner way to do this, please assist in any way you can.