I am trying to insert data from Kivy's textinput fields to sqlite3 database but arrive at the following issue. Code snippet
def save(self):
conn = Database.db_connect()
cursor = conn.cursor()
# kivy textinput widgets are assigned variable no, name
no = self.empid_text_input
name = self.empname_text_input.text
try:
save_index_sql="INSERT INTO EmpInfo (EmpID , EmpName) VALUES (?,?)"
conn.execute(save_index_sql, (no, name)) # Causes Error
conn.commit()
conn.close()
except sqlite3.IntegrityError as e:
print("Error: ",e)
# THROWS ERROR----> sqlite3.InterfaceError: Error binding parameter 0 - probably unsupported type.
Database file Emp.db contains the follwing tables & structure : EmpInfo & EmpImage
EmpInfo CREATE TABLE EmpInfo(EmpID integer PRIMARY KEY, EmpName text NOT NULL)
EmpImage CREATE TABLE EmpImage(EmpID integer PRIMARY KEY, EmpPhoto BLOB NOT NULL)
Casting gives the following results:
# conn.execute(save_index_sql,(int(no), str(name))) # RETURNS----> TypeError: int() argument must be a string, a bytes-like object or a number, not 'TextInput'
# conn.execute(save_index_sql, (str(no), str(name))) # RETURNS----> Error: datatype mismatch