im trying to insert multiple rows of data into at once into a table in pythong using sqlite3 and this is the code im using:
import sqlite3
import numpy as np
connection = sqlite3.connect("""HR_info.db""")
cursor = connection.cursor()
cursor.execute('''CREATE TABLE IF NOT EXISTS flu_jabs(staff_number integer PRIMARY KEY, flu_jab
text)''')
def insert(entitiy):
cursor.execute('''INSERT INTO flu_jab(staff_number,flu_jab) VALUES(?,?)''', entitiy)
x1 = np.zeros([1,2])
x2 = []
xs = []
for i in range(30):
#print('has staff id ',results[i][0],' recived a flue shot? (Y/N): ')
#x.append(input())
xs = 'Y '#input('0/1')
x1[0][0] = i
x1[0][1] = 0
insert(x1[0][0],x1[0][1])
print(x1)
however whatever i put in the argument of Insert() i get either a ProgrammingError:
ProgrammingError: Incorrect number of bindings supplied. The current statement uses 2, and there are 1 supplied.
or a TypeError:
TypeError: insert() takes 1 positional argument but 2 were given
i really dont understand what method i should be using or if there is a much simpler way in insting multiple rows of data into a table in SQL. All of the examples ive seen online about INSERT have been of single rows, if anyone could point me in the direction of an example of mulitple rows at once it would be just as useful