Python update SQLite DB Values At the moment I try to get used to SQLite and Python. I started with insert, select and so on. But now i want to get a bit further. 
Now I have a DB with 200 rows for testing and in want to update two values of each row in this case called "Test2" and "Test3". My problem is that those two values should be the value that they have +200 and +400 so i have to make an select before updating them (at least with my knowledge). 

I added a simple time measurement to my code to see if i will be able to make my code more efficient and faster!

At the moment it takes 0.7344 seconds for me to edit 200 rows of data. Which is pretty slow! Especially if i think to do it for bigger DB's.

Things I want to achieve:


Is it really necessary to make the select or could I use the present Data in any other way?
Make things faster! Is it possible to edit multiple rows at the same time? Like parallelized tasks?


Any other tips are welcome, as i try to improve myself!

Here is my code so far:

import sqlite3
import time

def database_test():
    # Open Database
    conn = sqlite3.connect('SQLite_Test.db')
    c = conn.cursor()

    i = 0

    for i in range(200):
        c.execute('SELECT Test2, Test3 FROM Test WHERE Test1 = ?',  (i,))

        DB_Values = []        
        DB_Values = c.fetchone()

        Value1 = DB_Values[0]+200
        Value2 = DB_Values[1]+400

        c.execute('''UPDATE Test SET Test2 = ?, Test3 = ? WHERE Test1= ?''', (Value1, Value2, i))
        i += 1  

    # Save (commit) the changes
    conn.commit() 


start_time = time.time()
database_test()
print("--- %s seconds ---" % round((time.time() - start_time),4))
SQL (and thus SQLite) support a variety of operators suitable (amongst others) in UPDATE statements.

This means that you can simplify your whole loop into a single statement:

query = '''
    UPDATE Test SET Test2 = (Test2 + ?), Test3 = (Test3 + ?)
    WHERE Test1 &gt;= 0 AND Test1 &lt; 200
'''
c.execute(query, (200, 400))




Also you should take the habit to use perf_counter instead of time to measure elapsed time. Or use the dedicated timeit module.