TextInput values cannot be saved on sqlite

283
April 29, 2017, at 03:10 AM

I'm new to Python and Kivy. Now, I am working on an application that uses python and I also use kivy for the interface. Anyway, my problem is I cannot save the text values that I input into the TextInput.

Here is a part of my code:

    from kivy.app import App
    from kivy.uix.boxlayout import BoxLayout
    from kivy.uix.screenmanager import Screen, ScreenManager 
    from kivy.uix.button import Button
    from kivy.properties import ObjectProperty
    from kivy.uix.textinput import TextInput
    import sqlite3
    conn=sqlite3.connect("Database.db")
    c = conn.cursor()
    def Screen(Screen)
       def __init__(self,**kwargs):
         super (ScreenOne,self).__init__(**kwargs)
         txt1 = TextInput(text='', multiline=False, hint_text="Employee ID")
         emp_id = txt1.text
         my_box1.add_widget(txt1)
         txt2 = TextInput(text='', multiline=False, hint_text="Name")
         name = txt2.text
         my_box1.add_widget(txt2)
         c.execute('CREATE TABLE IF NOT EXISTS Employees(EmployeeID INTEGER PRIMARY KEY,Name VARCHAR(30) NOT NULL)')
         c.execute("INSERT INTO Employees (EmployeeID,Name) VALUES (emp_id,name)")
         conn.commit()
         c.close()
         conn.close()

Error is datatype mismatch in c.execute("INSERT INTO ** line. Help me please.

READ ALSO
How to control EOL and leading spaces in Mako?

How to control EOL and leading spaces in Mako?

With the following, I would like to control the EOL:

217
How to search for a variable in a list of strings

How to search for a variable in a list of strings

I have very basic python knowledgeThis is my code so far: when i run this code the error UnboundLocalError: local variable 'response' referenced before assignment on line 7 displays

248
Trying to wrap my head around python property decorator [duplicate]

Trying to wrap my head around python property decorator [duplicate]

This question already has an answer here:

234